index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item :label="$t('危废名称')" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. :placeholder="$t('请输入') + $t('危废名称')"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item :label="$t('日期')" prop="incomingDate">
  14. <el-date-picker
  15. v-model="chooseDate"
  16. type="daterange"
  17. align="right"
  18. unlink-panels
  19. :range-separator="$t('至')"
  20. :start-placeholder="$t('开始日期')"
  21. :end-placeholder="$t('结束日期')"
  22. value-format="yyyy-MM-dd"
  23. :picker-options="pickerOptions">
  24. </el-date-picker>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  28. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button
  34. type="primary"
  35. icon="el-icon-plus"
  36. size="mini"
  37. @click="handleAdd"
  38. v-hasPermi="['ehs:barrelmonth:add']"
  39. >{{ $t('新增') }}</el-button>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button
  43. type="success"
  44. icon="el-icon-edit"
  45. size="mini"
  46. :disabled="single"
  47. @click="handleUpdate"
  48. v-hasPermi="['ehs:barrelmonth:edit']"
  49. >{{ $t('修改') }}</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. type="danger"
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['ehs:barrelmonth:remove']"
  59. >{{ $t('删除') }}</el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="info"
  64. icon="el-icon-upload2"
  65. size="mini"
  66. @click="handleImport"
  67. v-hasPermi="['ehs:barrelmonth:edit']"
  68. >{{ $t('导入') }}</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. icon="el-icon-download"
  74. size="mini"
  75. @click="handleExport"
  76. v-hasPermi="['ehs:barrelmonth:export']"
  77. >{{ $t('导出') }}</el-button>
  78. </el-col>
  79. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  80. </el-row>
  81. <el-table v-loading="loading" :data="barrelmonthList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  82. <el-table-column type="selection" width="55" align="center" />
  83. <el-table-column :label="$t('产废部门')" align="center" prop="plantCode" :formatter="plantCodeFormat" />
  84. <el-table-column :label="$t('危废名称')" align="center" prop="name" :show-overflow-tooltip="true"/>
  85. <el-table-column :label="$t('日期')" align="center" prop="incomingDate" width="100">
  86. <template slot-scope="scope">
  87. <span>{{ parseTime(scope.row.incomingDate, '{y}-{m}-{d}') }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column :label="$t('当月入库数量') + '(ton)'" align="center" prop="incomingQuantity" :show-overflow-tooltip="true"/>
  91. <el-table-column :label="$t('包装形式')" align="center" prop="packaging" :show-overflow-tooltip="true"/>
  92. <el-table-column :label="$t('容器数量')" align="center" prop="containers" :show-overflow-tooltip="true"/>
  93. <el-table-column :label="$t('存放位置')" align="center" prop="place" :show-overflow-tooltip="true"/>
  94. <el-table-column :label="$t('接收人')" align="center" prop="receiver" :show-overflow-tooltip="true"/>
  95. <el-table-column :label="$t('出库数量')" align="center" prop="deliveryQuantity" :show-overflow-tooltip="true"/>
  96. <el-table-column :label="$t('经手人')" align="center" prop="handler" :show-overflow-tooltip="true"/>
  97. <el-table-column :label="$t('出库方向')" align="center" prop="deliveryDirection" :show-overflow-tooltip="true"/>
  98. <el-table-column :label="$t('联系单号')" align="center" prop="sheetNumber" :show-overflow-tooltip="true"/>
  99. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  100. <template slot-scope="scope">
  101. <el-button
  102. size="mini"
  103. type="text"
  104. icon="el-icon-edit"
  105. @click="handleUpdate(scope.row)"
  106. v-hasPermi="['ehs:barrelmonth:edit']"
  107. >{{ $t('修改') }}</el-button>
  108. <el-button
  109. size="mini"
  110. type="text"
  111. icon="el-icon-delete"
  112. @click="handleDelete(scope.row)"
  113. v-hasPermi="['ehs:barrelmonth:remove']"
  114. >{{ $t('删除') }}</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 添加或修改废桶进出库统计日报对话框 -->
  126. <el-dialog v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  128. <el-form-item :label="$t('装置名称')" prop="plantCode">
  129. <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置名称')">
  130. <el-option
  131. v-for="dict in plantCodeOptions"
  132. :key="dict.dictValue"
  133. :label="dict.dictLabel"
  134. :value="dict.dictValue"
  135. ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item :label="$t('危废名称')" prop="name">
  139. <el-input v-model="form.name" :placeholder="$t('请输入') + $t('危废名称')" />
  140. </el-form-item>
  141. <el-form-item :label="$t('日期')" prop="incomingDate">
  142. <el-date-picker clearable size="small" style="width: 200px"
  143. v-model="form.incomingDate"
  144. type="date"
  145. value-format="yyyy-MM-dd"
  146. :placeholder="$t('请选择') + $t('日期')">
  147. </el-date-picker>
  148. </el-form-item>
  149. <el-form-item :label="$t('当月入库数量')" prop="incomingQuantity">
  150. <el-input v-model="form.incomingQuantity" :placeholder="$t('请输入') + $t('当月入库数量')" />
  151. </el-form-item>
  152. <el-form-item :label="$t('包装形式')" prop="packaging">
  153. <el-input v-model="form.packaging" :placeholder="$t('请输入') + $t('包装形式')" />
  154. </el-form-item>
  155. <el-form-item :label="$t('容器数量')" prop="containers">
  156. <el-input v-model="form.containers" :placeholder="$t('请输入') + $t('容器数量')" />
  157. </el-form-item>
  158. <el-form-item :label="$t('存放位置')" prop="place">
  159. <el-input v-model="form.place" :placeholder="$t('请输入') + $t('存放位置')" />
  160. </el-form-item>
  161. <el-form-item :label="$t('接收人')" prop="receiver">
  162. <el-input v-model="form.receiver" :placeholder="$t('请输入') + $t('接收人')" />
  163. </el-form-item>
  164. <el-form-item :label="$t('出库数量')" prop="deliveryQuantity">
  165. <el-input v-model="form.deliveryQuantity" :placeholder="$t('请输入') + $t('出库数量')" />
  166. </el-form-item>
  167. <el-form-item :label="$t('经手人')" prop="handler">
  168. <el-input v-model="form.handler" :placeholder="$t('请输入') + $t('经手人')" />
  169. </el-form-item>
  170. <el-form-item :label="$t('出库方向')" prop="deliveryDirection">
  171. <el-input v-model="form.deliveryDirection" :placeholder="$t('请输入') + $t('出库方向')" />
  172. </el-form-item>
  173. <el-form-item :label="$t('联系单号')" prop="sheetNumber">
  174. <el-input v-model="form.sheetNumber" :placeholder="$t('请输入') + $t('联系单号')" />
  175. </el-form-item>
  176. <el-form-item :label="$t('备注')" prop="remarks">
  177. <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')" />
  178. </el-form-item>
  179. <el-form-item :label="$t('归属部门')" prop="deptId">
  180. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  181. </el-form-item>
  182. </el-form>
  183. <div slot="footer" class="dialog-footer">
  184. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  185. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  186. </div>
  187. </el-dialog>
  188. <!-- 用户导入对话框 -->
  189. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  190. <el-upload
  191. ref="upload"
  192. :limit="1"
  193. accept=".xlsx, .xls"
  194. :headers="upload.headers"
  195. :action="upload.url"
  196. :disabled="upload.isUploading"
  197. :on-progress="handleFileUploadProgress"
  198. :on-success="handleFileSuccess"
  199. :auto-upload="false"
  200. drag
  201. >
  202. <i class="el-icon-upload"></i>
  203. <div class="el-upload__text">
  204. {{ $t('将文件拖到此处,或') }}
  205. <em>{{ $t('点击上传') }}</em>
  206. </div>
  207. <div class="el-upload__tip" slot="tip">
  208. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  209. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  210. </div>
  211. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  212. <input name="type" :value="upload.type" hidden />
  213. </form>
  214. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  215. </el-upload>
  216. <div slot="footer" class="dialog-footer">
  217. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  218. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  219. </div>
  220. </el-dialog>
  221. </div>
  222. </template>
  223. <script>
  224. import { listBarrelmonth, getBarrelmonth, delBarrelmonth, addBarrelmonth, updateBarrelmonth, exportBarrelmonth } from "@/api/ehs/barrelmonth";
  225. import { treeselect } from "@/api/system/dept";
  226. import { getToken } from "@/utils/auth";
  227. import Treeselect from "@riophae/vue-treeselect";
  228. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  229. export default {
  230. name: "Barrelmonth",
  231. components: { Treeselect },
  232. data() {
  233. return {
  234. // 遮罩层
  235. loading: true,
  236. // 选中数组
  237. ids: [],
  238. // 非单个禁用
  239. single: true,
  240. // 非多个禁用
  241. multiple: true,
  242. // 显示搜索条件
  243. showSearch: false,
  244. // 总条数
  245. total: 0,
  246. // 废桶进出库统计日报表格数据
  247. barrelmonthList: [],
  248. // 弹出层标题
  249. title: "",
  250. // 部门树选项
  251. deptOptions: undefined,
  252. clientHeight:300,
  253. // 是否显示弹出层
  254. open: false,
  255. // 装置字典
  256. plantCodeOptions: [],
  257. // 用户导入参数
  258. upload: {
  259. //下载模板请求地址
  260. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  261. //下载模板类型
  262. type: "barrelmonth",
  263. // 是否显示弹出层(用户导入)
  264. open: false,
  265. // 弹出层标题(用户导入)
  266. title: "",
  267. // 是否禁用上传
  268. isUploading: false,
  269. // 是否更新已经存在的用户数据
  270. updateSupport: 0,
  271. // 设置上传的请求头部
  272. headers: { Authorization: "Bearer " + getToken() },
  273. // 上传的地址
  274. url: process.env.VUE_APP_BASE_API + "/ehs/barrelmonth/importData"
  275. },
  276. // 查询参数
  277. queryParams: {
  278. pageNum: 1,
  279. pageSize: 20,
  280. plantCode: null,
  281. name: null,
  282. incomingDate: null,
  283. startDate: null,
  284. endDate: null,
  285. incomingQuantity: null,
  286. packaging: null,
  287. containers: null,
  288. place: null,
  289. deliveryQuantity: null,
  290. handler: null,
  291. deliveryDirection: null,
  292. sheetNumber: null,
  293. },
  294. //日期快速选择
  295. pickerOptions: {
  296. shortcuts: [{
  297. text: this.$t('最近一周'),
  298. onClick(picker) {
  299. const end = new Date();
  300. const start = new Date();
  301. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  302. picker.$emit('pick', [start, end]);
  303. }
  304. }, {
  305. text: this.$t('最近一个月'),
  306. onClick(picker) {
  307. const end = new Date();
  308. const start = new Date();
  309. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  310. picker.$emit('pick', [start, end]);
  311. }
  312. }, {
  313. text: this.$t('最近三个月'),
  314. onClick(picker) {
  315. const end = new Date();
  316. const start = new Date();
  317. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  318. picker.$emit('pick', [start, end]);
  319. }
  320. }]
  321. },
  322. //日期选择器
  323. chooseDate: [],
  324. // 表单参数
  325. form: {},
  326. // 表单校验
  327. rules: {
  328. plantCode: [
  329. { required: true, message: this.$t('装置') + this.$t('不能为空'), trigger: "change" }
  330. ],
  331. }
  332. };
  333. },
  334. watch: {
  335. // 根据名称筛选部门树
  336. deptName(val) {
  337. this.$refs.tree.filter(val);
  338. }
  339. },
  340. created() {
  341. //设置表格高度对应屏幕高度
  342. this.$nextTick(() => {
  343. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  344. })
  345. this.getList();
  346. this.getTreeselect();
  347. this.getDicts("PLANT_DIVIDE").then(response => {
  348. this.plantCodeOptions = response.data;
  349. });
  350. },
  351. methods: {
  352. /** 查询废桶进出库统计日报列表 */
  353. getList() {
  354. this.loading = true;
  355. listBarrelmonth(this.queryParams).then(response => {
  356. this.barrelmonthList = response.rows;
  357. this.total = response.total;
  358. this.loading = false;
  359. });
  360. },
  361. /** 查询部门下拉树结构 */
  362. getTreeselect() {
  363. treeselect().then(response => {
  364. this.deptOptions = response.data;
  365. });
  366. },
  367. // 装置字典翻译
  368. plantCodeFormat(row, column) {
  369. return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
  370. },
  371. // 取消按钮
  372. cancel() {
  373. this.open = false;
  374. this.reset();
  375. },
  376. // 表单重置
  377. reset() {
  378. this.form = {
  379. id: null,
  380. plantCode: null,
  381. name: null,
  382. incomingDate: null,
  383. startDate: null,
  384. endDate: null,
  385. incomingQuantity: null,
  386. packaging: null,
  387. containers: null,
  388. place: null,
  389. deliveryQuantity: null,
  390. handler: null,
  391. deliveryDirection: null,
  392. sheetNumber: null,
  393. delFlag: null,
  394. createrCode: null,
  395. createdate: null,
  396. updaterCode: null,
  397. updatedate: null,
  398. deptId: null,
  399. remarks: null
  400. };
  401. this.resetForm("form");
  402. },
  403. /** 搜索按钮操作 */
  404. handleQuery() {
  405. this.queryParams.pageNum = 1;
  406. this.queryParams.startDate = this.chooseDate[0];
  407. this.queryParams.endDate = this.chooseDate[1];
  408. this.getList();
  409. },
  410. /** 重置按钮操作 */
  411. resetQuery() {
  412. this.resetForm("queryForm");
  413. this.chooseDate = "";
  414. this.handleQuery();
  415. },
  416. // 多选框选中数据
  417. handleSelectionChange(selection) {
  418. this.ids = selection.map(item => item.id)
  419. this.single = selection.length!==1
  420. this.multiple = !selection.length
  421. },
  422. /** 新增按钮操作 */
  423. handleAdd() {
  424. this.reset();
  425. this.open = true;
  426. this.title = this.$t('新增') + " " + this.$t('废桶进出库统计日报');
  427. },
  428. /** 修改按钮操作 */
  429. handleUpdate(row) {
  430. this.reset();
  431. const id = row.id || this.ids
  432. getBarrelmonth(id).then(response => {
  433. this.form = response.data;
  434. this.open = true;
  435. this.title = this.$t('修改') + this.$t('废桶进出库统计日报');
  436. });
  437. },
  438. /** 提交按钮 */
  439. submitForm() {
  440. this.$refs["form"].validate(valid => {
  441. if (valid) {
  442. if (this.form.id != null) {
  443. updateBarrelmonth(this.form).then(response => {
  444. this.msgSuccess(this.$t('修改成功'));
  445. this.open = false;
  446. this.getList();
  447. });
  448. } else {
  449. addBarrelmonth(this.form).then(response => {
  450. this.msgSuccess(this.$t('新增成功'));
  451. this.open = false;
  452. this.getList();
  453. });
  454. }
  455. }
  456. });
  457. },
  458. /** 删除按钮操作 */
  459. handleDelete(row) {
  460. const ids = row.id || this.ids;
  461. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  462. confirmButtonText: this.$t('确定'),
  463. cancelButtonText: this.$t('取消'),
  464. type: "warning"
  465. }).then(function() {
  466. return delBarrelmonth(ids);
  467. }).then(() => {
  468. this.getList();
  469. this.msgSuccess(this.$t('删除成功'));
  470. })
  471. },
  472. /** 导出按钮操作 */
  473. handleExport() {
  474. const queryParams = this.queryParams;
  475. this.$confirm( this.$t('是否确认导出所有废桶进出库统计日报数据项?'), this.$t('警告'), {
  476. confirmButtonText: this.$t('确定'),
  477. cancelButtonText: this.$t('取消'),
  478. type: "warning"
  479. }).then(function() {
  480. return exportBarrelmonth(queryParams);
  481. }).then(response => {
  482. this.download(response.msg);
  483. })
  484. },
  485. /** 导入按钮操作 */
  486. handleImport() {
  487. this.upload.title = this.$t('用户导入');
  488. this.upload.open = true;
  489. },
  490. /** 下载模板操作 */
  491. importTemplate() {
  492. this.$refs['downloadFileForm'].submit()
  493. },
  494. // 文件上传中处理
  495. handleFileUploadProgress(event, file, fileList) {
  496. this.upload.isUploading = true;
  497. },
  498. // 文件上传成功处理
  499. handleFileSuccess(response, file, fileList) {
  500. this.upload.open = false;
  501. this.upload.isUploading = false;
  502. this.$refs.upload.clearFiles();
  503. if (response.data[0] != null) {
  504. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  505. }else {
  506. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  507. }
  508. this.getList();
  509. },
  510. // 提交上传文件
  511. submitFileForm() {
  512. this.$refs.upload.submit();
  513. }
  514. }
  515. };
  516. </script>