index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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="Utility consumption quantity" prop="utilityQuantity">
  5. <el-input
  6. v-model="queryParams.utilityQuantity"
  7. placeholder="请输入Utility consumption quantity"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="Quantity" prop="quantity">
  14. <el-input
  15. v-model="queryParams.quantity"
  16. placeholder="请输入Quantity"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="Unit" prop="unit">
  23. <el-input
  24. v-model="queryParams.unit"
  25. placeholder="请输入Unit"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="Note" prop="note">
  32. <el-input
  33. v-model="queryParams.note"
  34. placeholder="请输入Note"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  42. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  43. </el-form-item>
  44. </el-form>
  45. <el-row :gutter="10" class="mb8">
  46. <!-- <el-col :span="1.5">
  47. <el-button
  48. type="primary"
  49. icon="el-icon-plus"
  50. size="mini"
  51. @click="handleAdd"
  52. v-hasPermi="['pssr:material:add']"
  53. v-if="isApprove==0"
  54. >新增
  55. </el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="success"
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['pssr:material:edit']"
  65. v-if="isApprove==0"
  66. >修改
  67. </el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="danger"
  72. icon="el-icon-delete"
  73. size="mini"
  74. :disabled="multiple"
  75. @click="handleDelete"
  76. v-hasPermi="['pssr:material:remove']"
  77. v-if="isApprove==0"
  78. >删除
  79. </el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="info"
  84. icon="el-icon-upload2"
  85. size="mini"
  86. @click="handleImport"
  87. v-hasPermi="['pssr:material:edit']"
  88. v-if="isApprove==0"
  89. >导入
  90. </el-button>
  91. </el-col>-->
  92. <el-col :span="1.5">
  93. <el-button
  94. type="warning"
  95. icon="el-icon-download"
  96. size="mini"
  97. @click="handleExport"
  98. v-hasPermi="['pssr:material:export']"
  99. v-if="isApprove==0"
  100. >导出
  101. </el-button>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="success"
  106. icon="el-icon-edit"
  107. size="mini"
  108. :disabled="multiple"
  109. @click="handleBatch"
  110. v-hasPermi="['pssr:material:edit']"
  111. >批量操作</el-button>
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="success"
  116. icon="el-icon-s-promotion"
  117. size="mini"
  118. @click="handleApprove"
  119. v-if="isApprove==0"
  120. v-hasPermi="['pssr:material:edit']"
  121. >发起审批
  122. </el-button>
  123. </el-col>
  124. <el-col :span="1.5">
  125. <el-button
  126. type="primary"
  127. icon="el-icon-check"
  128. size="mini"
  129. v-if="isApprove==4||isApprove==5"
  130. @click="handleConfirmApprove"
  131. v-hasPermi="['pssr:material:edit']"
  132. >确认
  133. </el-button>
  134. </el-col>
  135. <el-col :span="1.5">
  136. <el-button
  137. type="danger"
  138. icon="el-icon-refresh-left"
  139. size="mini"
  140. v-if="isApprove==2"
  141. :disabled="multiple"
  142. @click="handleTurnDown"
  143. v-hasPermi="['pssr:material:edit']"
  144. >驳回
  145. </el-button>
  146. </el-col>
  147. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  148. </el-row>
  149. <el-table v-loading="loading" :data="materialList" @selection-change="handleSelectionChange" :height="clientHeight"
  150. border>
  151. <el-table-column type="selection" width="55" align="center"/>
  152. <el-table-column label="审批状态" align="center" prop="approveStatus" :show-overflow-tooltip="true">
  153. <template slot-scope="scope">
  154. <el-tag v-if="scope.row.approveStatus==0">未审批</el-tag>
  155. <el-tag v-if="scope.row.approveStatus==1" type="warning">待确认</el-tag>
  156. <el-tag v-if="scope.row.approveStatus==3" type="success">已确认1</el-tag>
  157. <el-tag v-if="scope.row.approveStatus==2" type="success">已确认2</el-tag>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="Utility consumption quantity" align="center" prop="utilityQuantity"
  161. :show-overflow-tooltip="true"/>
  162. <el-table-column label="Quantity" align="center" prop="quantity" :show-overflow-tooltip="true"/>
  163. <el-table-column label="Unit" align="center" prop="unit" :show-overflow-tooltip="true"/>
  164. <el-table-column label="Note" align="center" prop="note" :show-overflow-tooltip="true"/>
  165. <el-table-column label="确认人1" align="center" prop="confirm1" :show-overflow-tooltip="true">
  166. <template slot-scope="scope">
  167. <span>{{ userFormat(scope.row.confirm1) }}</span>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="确认人2" align="center" prop="confirm2" :show-overflow-tooltip="true">
  171. <template slot-scope="scope">
  172. <span>{{ userFormat(scope.row.confirm2) }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="确认时间" align="center" prop="confirmationDate">
  176. <template slot-scope="scope">
  177. <span>{{ parseTime(scope.row.confirmationDate, '{y}-{m}-{d}') }}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  181. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  182. <template slot-scope="scope">
  183. <el-button
  184. size="mini"
  185. type="text"
  186. icon="el-icon-edit"
  187. @click="handleUpdate(scope.row)"
  188. v-hasPermi="['pssr:material:edit']"
  189. >修改
  190. </el-button>
  191. <!-- <el-button
  192. size="mini"
  193. type="text"
  194. icon="el-icon-delete"
  195. @click="handleDelete(scope.row)"
  196. v-hasPermi="['pssr:material:remove']"
  197. >删除
  198. </el-button>-->
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. <pagination
  203. v-show="total>0"
  204. :total="total"
  205. :page.sync="queryParams.pageNum"
  206. :limit.sync="queryParams.pageSize"
  207. @pagination="getList"
  208. />
  209. <!-- 添加或修改原料对话框 -->
  210. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
  211. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  212. <el-form-item label="Quantity" prop="quantity">
  213. <el-input v-model="form.quantity" placeholder="请输入Quantity"/>
  214. </el-form-item>
  215. <el-form-item label="Note" prop="note">
  216. <el-input v-model="form.note" placeholder="请输入Note"/>
  217. </el-form-item>
  218. <el-form-item label="确认人1" prop="confirm1">
  219. <el-select v-model="form.confirm1" filterable placeholder="请选择确认人1">
  220. <el-option v-for="user in userOptions"
  221. :label="user.nickName"
  222. :value="user.userId+''"
  223. :key="user.userId"/>
  224. </el-select>
  225. </el-form-item>
  226. <el-form-item label="确认人2" prop="confirm2">
  227. <el-select v-model="form.confirm2" filterable placeholder="请选择确认人1">
  228. <el-option v-for="user in userOptions"
  229. :label="user.nickName"
  230. :value="user.userId+''"
  231. :key="user.userId"/>
  232. </el-select>
  233. </el-form-item>
  234. <el-form-item label="备注" prop="remarks">
  235. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  236. </el-form-item>
  237. </el-form>
  238. <div slot="footer" class="dialog-footer">
  239. <el-button type="primary" @click="submitForm">确 定</el-button>
  240. <el-button @click="cancel">取 消</el-button>
  241. </div>
  242. </el-dialog>
  243. <el-dialog :close-on-click-modal="false" title="批量修改" :visible.sync="openBatch" width="500px" append-to-body>
  244. <el-form ref="form" :model="form" label-width="80px">
  245. <el-form-item>
  246. <span>已选择 {{ ids.length }} 条数据</span>
  247. </el-form-item>
  248. <el-form-item label="确认人1" prop="confirm1">
  249. <el-select v-model="form.confirm1" filterable placeholder="请选择确认人1">
  250. <el-option v-for="user in userOptions"
  251. :label="user.nickName"
  252. :value="user.userId+''"
  253. :key="user.userId"/>
  254. </el-select>
  255. </el-form-item>
  256. <el-form-item label="确认人2" prop="confirm2">
  257. <el-select v-model="form.confirm2" filterable placeholder="请选择确认人1">
  258. <el-option v-for="user in userOptions"
  259. :label="user.nickName"
  260. :value="user.userId+''"
  261. :key="user.userId"/>
  262. </el-select>
  263. </el-form-item>
  264. <el-form-item label="时间确认" prop="confirmationDate">
  265. <el-date-picker clearable size="small" style="width: 200px"
  266. v-model="form.confirmationDate"
  267. type="date"
  268. value-format="yyyy-MM-dd"
  269. placeholder="选择时间">
  270. </el-date-picker>
  271. </el-form-item>
  272. <el-form-item label="备注" prop="remarks">
  273. <el-input v-model="form.remarks" placeholder="请输入备注" />
  274. </el-form-item>
  275. </el-form>
  276. <div slot="footer" class="dialog-footer">
  277. <el-button type="primary" @click="submitFormBatch">确 定</el-button>
  278. <el-button @click="cancelBatch">取 消</el-button>
  279. </div>
  280. </el-dialog>
  281. <!-- 用户导入对话框 -->
  282. <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px"
  283. append-to-body>
  284. <el-upload
  285. ref="upload"
  286. :limit="1"
  287. accept=".xlsx, .xls"
  288. :headers="upload.headers"
  289. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  290. :disabled="upload.isUploading"
  291. :on-progress="handleFileUploadProgress"
  292. :on-success="handleFileSuccess"
  293. :auto-upload="false"
  294. drag
  295. >
  296. <i class="el-icon-upload"></i>
  297. <div class="el-upload__text">
  298. 将文件拖到此处,或
  299. <em>点击上传</em>
  300. </div>
  301. <div class="el-upload__tip" slot="tip">
  302. <el-checkbox v-model="upload.updateSupport"/>
  303. 是否更新已经存在的用户数据
  304. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  305. </div>
  306. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  307. </el-upload>
  308. <div slot="footer" class="dialog-footer">
  309. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  310. <el-button @click="upload.open = false">取 消</el-button>
  311. </div>
  312. </el-dialog>
  313. </div>
  314. </template>
  315. <script>
  316. import {
  317. addMaterial,
  318. delMaterial,
  319. exportMaterial,
  320. getMaterial, handleConfirmMaterial, handleTurnDownMaterial,
  321. importTemplate,
  322. listMaterial,
  323. updateMaterial,
  324. updateMaterialBatch
  325. } from "@/api/pssr/material";
  326. import {treeselect} from "@/api/system/dept";
  327. import {getToken} from "@/utils/auth";
  328. import Treeselect from "@riophae/vue-treeselect";
  329. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  330. import {doApprove} from "@/api/pssr/approve";
  331. import {listUserNoPage} from "@/api/system/user";
  332. export default {
  333. dicts: ['pssr_approve_status'],
  334. name: "Material",
  335. components: {Treeselect},
  336. props: {
  337. subId: {
  338. type: Number,
  339. default: 0
  340. },
  341. isApprove: {
  342. type: Number,
  343. default: 0
  344. },
  345. },
  346. data() {
  347. return {
  348. userOptions: [],
  349. // 遮罩层
  350. loading: true,
  351. // 选中数组
  352. ids: [],
  353. // 非单个禁用
  354. single: true,
  355. // 非多个禁用
  356. multiple: true,
  357. // 显示搜索条件
  358. showSearch: false,
  359. // 总条数
  360. total: 0,
  361. // 原料表格数据
  362. materialList: [],
  363. // 弹出层标题
  364. title: "",
  365. // 部门树选项
  366. deptOptions: undefined,
  367. clientHeight: 300,
  368. // 是否显示弹出层
  369. open: false,
  370. openBatch: false,
  371. // 用户导入参数
  372. upload: {
  373. // 是否显示弹出层(用户导入)
  374. open: false,
  375. // 弹出层标题(用户导入)
  376. title: "",
  377. // 是否禁用上传
  378. isUploading: false,
  379. // 是否更新已经存在的用户数据
  380. updateSupport: 0,
  381. // 设置上传的请求头部
  382. headers: {Authorization: "Bearer " + getToken()},
  383. // 上传的地址
  384. url: process.env.VUE_APP_BASE_API + "/pssr/material/importData"
  385. },
  386. // 查询参数
  387. queryParams: {
  388. pageNum: 1,
  389. pageSize: 20,
  390. subId: this.subId,
  391. approveId: null,
  392. utilityQuantity: null,
  393. quantity: null,
  394. unit: null,
  395. note: null,
  396. confirm: null,
  397. confirmationDate: null,
  398. createrCode: null,
  399. createdate: null,
  400. updaterCode: null,
  401. updatedate: null,
  402. deptId: null,
  403. remarks: null
  404. },
  405. // 表单参数
  406. form: {},
  407. // 表单校验
  408. rules: {
  409. note: [
  410. {required: true, message: "Note不能为空", trigger: "blur"}
  411. ],
  412. quantity: [
  413. {required: true, message: "Quantity不能为空", trigger: "blur"}
  414. ],
  415. confirm1: [
  416. {required: true, message: "确认人1不能为空", trigger: "blur"}
  417. ],
  418. confirm2: [
  419. {required: true, message: "确认人2不能为空", trigger: "blur"}
  420. ],}
  421. };
  422. },
  423. watch: {
  424. // 根据名称筛选部门树
  425. deptName(val) {
  426. this.$refs.tree.filter(val);
  427. }
  428. },
  429. created() {
  430. //设置表格高度对应屏幕高度
  431. this.$nextTick(() => {
  432. this.clientHeight = document.body.clientHeight - 350
  433. })
  434. this.getList();
  435. this.getTreeselect();
  436. listUserNoPage({}).then(res => {
  437. this.userOptions = res.data
  438. });
  439. },
  440. methods: {
  441. /** 查询原料列表 */
  442. getList() {
  443. this.loading = true;
  444. listMaterial(this.queryParams).then(response => {
  445. this.materialList = response.rows;
  446. this.total = response.total;
  447. this.loading = false;
  448. });
  449. },
  450. /** 查询部门下拉树结构 */
  451. getTreeselect() {
  452. treeselect().then(response => {
  453. this.deptOptions = response.data;
  454. });
  455. },
  456. // 取消按钮
  457. cancel() {
  458. this.open = false;
  459. this.reset();
  460. },
  461. // 表单重置
  462. reset() {
  463. this.form = {
  464. id: null,
  465. subId: this.subId,
  466. approveId: null,
  467. utilityQuantity: null,
  468. quantity: null,
  469. unit: null,
  470. note: null,
  471. confirm: null,
  472. confirmationDate: null,
  473. delFlag: null,
  474. createrCode: null,
  475. createdate: null,
  476. updaterCode: null,
  477. updatedate: null,
  478. deptId: null,
  479. remarks: null
  480. };
  481. this.resetForm("form");
  482. },
  483. /** 搜索按钮操作 */
  484. handleQuery() {
  485. this.queryParams.pageNum = 1;
  486. this.getList();
  487. },
  488. /** 重置按钮操作 */
  489. resetQuery() {
  490. this.resetForm("queryForm");
  491. this.handleQuery();
  492. },
  493. // 多选框选中数据
  494. handleSelectionChange(selection) {
  495. this.ids = selection.map(item => item.id)
  496. this.single = selection.length !== 1
  497. this.multiple = !selection.length
  498. },
  499. /** 新增按钮操作 */
  500. handleAdd() {
  501. this.reset();
  502. this.open = true;
  503. this.title = "添加原料";
  504. },
  505. handleBatch(){
  506. this.reset();
  507. this.openBatch = true
  508. },
  509. // 取消按钮
  510. cancelBatch() {
  511. this.openBatch = false;
  512. this.reset();
  513. },
  514. /** 提交按钮 */
  515. submitFormBatch() {
  516. this.$refs["form"].validate(valid => {
  517. if (valid) {
  518. this.form.ids = this.ids
  519. updateMaterialBatch(this.form).then(response => {
  520. this.msgSuccess("修改成功");
  521. this.open = false;
  522. this.getList();
  523. });
  524. }
  525. });
  526. },
  527. /** 修改按钮操作 */
  528. handleUpdate(row) {
  529. this.reset();
  530. const id = row.id || this.ids
  531. getMaterial(id).then(response => {
  532. this.form = response.data;
  533. this.open = true;
  534. this.title = "修改原料";
  535. });
  536. },
  537. /** 提交按钮 */
  538. submitForm() {
  539. this.$refs["form"].validate(valid => {
  540. if (valid) {
  541. if (this.form.id != null) {
  542. updateMaterial(this.form).then(response => {
  543. this.msgSuccess("修改成功");
  544. this.open = false;
  545. this.getList();
  546. });
  547. } else {
  548. addMaterial(this.form).then(response => {
  549. this.msgSuccess("新增成功");
  550. this.open = false;
  551. this.getList();
  552. });
  553. }
  554. }
  555. });
  556. },
  557. /** 删除按钮操作 */
  558. handleDelete(row) {
  559. const ids = row.id || this.ids;
  560. this.$confirm('是否确认删除?', "警告", {
  561. confirmButtonText: "确定",
  562. cancelButtonText: "取消",
  563. type: "warning"
  564. }).then(function () {
  565. return delMaterial(ids);
  566. }).then(() => {
  567. this.getList();
  568. this.msgSuccess("删除成功");
  569. })
  570. },
  571. /** 导出按钮操作 */
  572. handleExport() {
  573. const queryParams = this.queryParams;
  574. this.$confirm('是否确认导出所有原料数据项?', "警告", {
  575. confirmButtonText: "确定",
  576. cancelButtonText: "取消",
  577. type: "warning"
  578. }).then(function () {
  579. return exportMaterial(queryParams);
  580. }).then(response => {
  581. this.download(response.msg);
  582. })
  583. },
  584. /** 导入按钮操作 */
  585. handleImport() {
  586. this.upload.title = "用户导入";
  587. this.upload.open = true;
  588. },
  589. /** 下载模板操作 */
  590. importTemplate() {
  591. importTemplate().then(response => {
  592. this.download(response.msg);
  593. });
  594. },
  595. // 文件上传中处理
  596. handleFileUploadProgress(event, file, fileList) {
  597. this.upload.isUploading = true;
  598. },
  599. // 文件上传成功处理
  600. handleFileSuccess(response, file, fileList) {
  601. this.upload.open = false;
  602. this.upload.isUploading = false;
  603. this.$refs.upload.clearFiles();
  604. this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
  605. this.getList();
  606. },
  607. // 提交上传文件
  608. submitFileForm() {
  609. this.$refs.upload.submit();
  610. },
  611. /** 确认按钮操作*/
  612. handleApprove() {
  613. doApprove(this.subId).then(res => {
  614. this.msgSuccess("已发起确认流程");
  615. this.getList();
  616. })
  617. },
  618. handleConfirmApprove() {
  619. let data = {
  620. ids: this.ids,
  621. subId: this.subId,
  622. taskType: this.isApprove
  623. }
  624. handleConfirmMaterial(data).then(res => {
  625. this.msgSuccess("确认成功");
  626. this.getList()
  627. this.$emit('refreshHisList');
  628. })
  629. },
  630. handleTurnDown(val) {
  631. this.$prompt('请输入驳回原因', '提示', {
  632. confirmButtonText: '确认驳回',
  633. cancelButtonText: '取消',
  634. }).then(({value}) => {
  635. let data = {
  636. ids: this.ids,
  637. subId: this.subId,
  638. remarks: value
  639. }
  640. handleTurnDownMaterial(data).then(res => {
  641. this.msgSuccess("驳回成功");
  642. })
  643. }).catch(() => {
  644. this.$message({
  645. type: 'info',
  646. message: '取消驳回'
  647. });
  648. });
  649. },
  650. userFormat(userId) {
  651. for (let item of this.userOptions) {
  652. if (item.userId == userId) {
  653. return item.nickName
  654. }
  655. }
  656. },
  657. }
  658. };
  659. </script>