addOrEditDialog.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addOrEditDialogFlag"
  6. :title="title"
  7. :close-on-click-modal="false"
  8. width="70%"
  9. :before-close="cancel"
  10. :maxable="true"
  11. :resizable="true"
  12. >
  13. <div class="switch" v-if="title == '详情'">
  14. <div class="switch_left">
  15. <ul>
  16. <li
  17. v-for="item in tabOptions"
  18. :key="item.key"
  19. :class="{ active: activeComp == item.key }"
  20. @click="activeComp = item.key"
  21. >
  22. {{ item.name }}
  23. </li>
  24. </ul>
  25. </div>
  26. </div>
  27. <el-form
  28. ref="form"
  29. :model="form"
  30. label-width="120px"
  31. class="el-form-box"
  32. v-if="activeComp == 'main'"
  33. :rules="rules"
  34. >
  35. <headerTitle title="基本信息"></headerTitle>
  36. <el-row :gutter="12">
  37. <el-col :span="8" v-if="title != '新建'">
  38. <el-form-item label="编码" prop="code">
  39. <el-input
  40. v-model="form.code"
  41. placeholder="请输入"
  42. :disabled="true"
  43. />
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="8">
  47. <el-form-item label="名称" prop="name">
  48. <el-input
  49. clearable
  50. v-model="form.name"
  51. :disabled="title == '详情'"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="8">
  56. <el-form-item label="来源单据类型" prop="relationType">
  57. <el-input v-model="form.relationTypeName" :disabled="true" />
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="8">
  61. <el-form-item label="来源单据编码" prop="relationCode">
  62. <el-input
  63. v-model="form.relationCode"
  64. :disabled="title == '详情'"
  65. redaonly
  66. @click.native="openDialog"
  67. />
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="8">
  71. <el-form-item label="来源单据名称" prop="relationName">
  72. <el-input
  73. clearable
  74. v-model="form.relationName"
  75. :disabled="title == '详情'"
  76. />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8" v-if="title != '新建'">
  80. <el-form-item label="创建人" prop="createUserName">
  81. <el-input
  82. clearable
  83. v-model="form.createUserName"
  84. :disabled="true"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="8" v-if="title != '新建'">
  89. <el-form-item label="创建时间" prop="createTime">
  90. <el-input clearable v-model="form.createTime" :disabled="true" />
  91. </el-form-item>
  92. </el-col>
  93. </el-row>
  94. <headerTitle title="物品清单" style="margin-top: 30px"></headerTitle>
  95. <ele-pro-table
  96. ref="table"
  97. :needPage="false"
  98. :columns="columns"
  99. :toolkit="[]"
  100. :datasource="form.detailList"
  101. row-key="id"
  102. :maxHeight="400"
  103. >
  104. <template v-slot:headerExceptionDispose="{ column }">
  105. <span class="is-required">{{ column.label }}</span>
  106. </template>
  107. <template v-slot:exceptionDispose="scope">
  108. <el-select
  109. v-model="scope.row.exceptionDispose"
  110. :disabled="title == '详情'"
  111. placeholder="请选择"
  112. >
  113. <el-option
  114. v-for="item in options"
  115. :key="item.value"
  116. :label="item.label"
  117. :value="item.value"
  118. >
  119. </el-option>
  120. </el-select>
  121. </template>
  122. <template v-slot:describes="scope">
  123. <el-input v-model="scope.row.describes" placeholder="请输入">
  124. </el-input>
  125. </template>
  126. <template v-slot:exceptionDetermine="scope">
  127. <el-select
  128. v-model="scope.row.exceptionDetermine"
  129. :disabled="title == '详情'"
  130. placeholder="请选择"
  131. >
  132. <el-option
  133. v-for="item in options1"
  134. :key="item.value"
  135. :label="item.label"
  136. :value="item.value"
  137. >
  138. </el-option>
  139. </el-select>
  140. </template>
  141. <template v-slot:totalCount="scope">
  142. <el-input
  143. v-model="scope.row.totalCount"
  144. type="number"
  145. placeholder="请输入"
  146. ></el-input>
  147. </template>
  148. <!-- 操作列 -->
  149. <template v-slot:action="scope" v-if="title != '详情'">
  150. <el-popconfirm
  151. class="ele-action"
  152. title="确定要删除吗?"
  153. @confirm="remove(scope.$index)"
  154. >
  155. <template v-slot:reference>
  156. <el-link type="danger" :underline="false" icon="el-icon-delete">
  157. 删除
  158. </el-link>
  159. </template>
  160. </el-popconfirm>
  161. </template>
  162. </ele-pro-table>
  163. </el-form>
  164. <div slot="footer" class="footer">
  165. <el-button
  166. type="primary"
  167. @click="save"
  168. v-click-once
  169. v-if="title != '详情'"
  170. >保存</el-button
  171. >
  172. <el-button
  173. type="primary"
  174. @click="save('sub')"
  175. v-click-once
  176. v-if="title != '详情'"
  177. >提交</el-button
  178. >
  179. <el-button @click="cancel">返回</el-button>
  180. </div>
  181. <bpmDetail
  182. :key="activeComp"
  183. v-if="activeComp === 'bpm' && form.processInstanceId"
  184. :id="form.processInstanceId"
  185. ></bpmDetail>
  186. <process-submit-dialog
  187. :isNotNeedProcess="false"
  188. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  189. v-if="processSubmitDialogFlag"
  190. ref="processSubmitDialogRef"
  191. @reload="reload"
  192. ></process-submit-dialog>
  193. <sendConfirmDialog
  194. ref="sendConfirmDialogRef"
  195. @changeParent="changeParent"
  196. ></sendConfirmDialog>
  197. <receiveTListDialog
  198. ref="receiveTListDialogRef"
  199. @changeParent="changeParent"
  200. ></receiveTListDialog>
  201. </ele-modal>
  202. </template>
  203. <script>
  204. import dictMixins from '@/mixins/dictMixins';
  205. import { getById, update, save } from '@/api/exceptionManagement/index';
  206. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  207. import { getSendSaleOrderConfirmDetail } from '@/api/saleManage/invoiceConfirm';
  208. import { getReceiveConfirmDetail } from '@/api/purchasingManage/invoiceConfirm';
  209. import { relationTypeOption } from '@/enum/dict.js';
  210. import bpmDetail from '@/views/bpm/processInstance/detail.vue';
  211. import sendConfirmDialog from '@/views/saleManage/saleOrder/invoiceConfirm/components/sendConfirmDialog.vue';
  212. import receiveTListDialog from '@/views/purchasingManage/purchaseOrder/invoiceConfirm/components/receiveTListDialog.vue';
  213. import { getCurrentUser, setCurrentUser } from '@/utils/token-util';
  214. const def = {
  215. name: '',
  216. relationCode: '',
  217. relationType: '',
  218. relationName: '',
  219. relationTypeName: '',
  220. relationId: '',
  221. formCreateUserId: '',
  222. detailList: [],
  223. currentUser: '',
  224. businessId: ''
  225. };
  226. export default {
  227. mixins: [dictMixins],
  228. components: {
  229. processSubmitDialog,
  230. bpmDetail,
  231. sendConfirmDialog,
  232. receiveTListDialog
  233. },
  234. props: {
  235. // 1: 销售订单, 2: 采购订单
  236. relationType: {
  237. default: 1
  238. }
  239. },
  240. created() {
  241. this.currentUser = getCurrentUser();
  242. console.log(this.currentUser);
  243. },
  244. data() {
  245. return {
  246. activeComp: 'main',
  247. tabOptions: [
  248. { key: 'main', name: '处置详情' },
  249. { key: 'bpm', name: '流程详情' }
  250. ],
  251. title: '',
  252. addOrEditDialogFlag: false,
  253. fullscreen: false,
  254. processSubmitDialogFlag: false,
  255. rules: {
  256. name: [{ required: true, message: '请输入名称', trigger: 'change' }],
  257. relationCode: [
  258. { required: true, message: '请选择来源', trigger: 'change' }
  259. ]
  260. },
  261. form: { ...def }
  262. };
  263. },
  264. computed: {
  265. columns() {
  266. return [
  267. {
  268. width: 45,
  269. type: 'index',
  270. columnKey: 'index',
  271. align: 'center',
  272. fixed: 'left'
  273. },
  274. {
  275. width: 220,
  276. prop: 'exceptionDetermine',
  277. label: '异常类型',
  278. slot: 'exceptionDetermine',
  279. fixed: 'left',
  280. align: 'center',
  281. headerSlot: 'headerExceptionDispose'
  282. },
  283. {
  284. width: 220,
  285. prop: 'exceptionDispose',
  286. label: '处置方式',
  287. slot: 'exceptionDispose',
  288. fixed: 'left',
  289. align: 'center',
  290. headerSlot: 'headerExceptionDispose'
  291. },
  292. {
  293. minWidth: 160,
  294. prop: 'productCode',
  295. label: '编码',
  296. showOverflowTooltip: true,
  297. align: 'center'
  298. },
  299. {
  300. minWidth: 120,
  301. prop: 'productName',
  302. label: '名称',
  303. showOverflowTooltip: true,
  304. align: 'center'
  305. },
  306. {
  307. width: 120,
  308. prop: 'specification',
  309. label: '规格',
  310. slot: 'specification',
  311. align: 'center'
  312. },
  313. {
  314. width: 120,
  315. prop: 'modelType',
  316. label: '型号',
  317. slot: 'modelType',
  318. align: 'center'
  319. },
  320. {
  321. width: 120,
  322. prop: 'productBrand',
  323. label: '牌号',
  324. align: 'center'
  325. },
  326. // {
  327. // minWidth: 100,
  328. // prop: 'saleCount',
  329. // label: '发货数量',
  330. // showOverflowTooltip: true,
  331. // align: 'center'
  332. // },
  333. {
  334. minWidth: 100,
  335. prop: 'totalCount',
  336. slot: 'totalCount',
  337. label: '异常数量',
  338. showOverflowTooltip: true,
  339. align: 'center'
  340. },
  341. {
  342. minWidth: 160,
  343. prop: 'batchNo',
  344. label: '批次号',
  345. showOverflowTooltip: true,
  346. slot: 'batchNo',
  347. align: 'center'
  348. },
  349. {
  350. minWidth: 160,
  351. prop: 'barcodes',
  352. label: '发货条码',
  353. showOverflowTooltip: true,
  354. slot: 'barcodes',
  355. align: 'center'
  356. },
  357. {
  358. minWidth: 120,
  359. prop: 'materielDesignation',
  360. label: '物料代号',
  361. showOverflowTooltip: true,
  362. align: 'center'
  363. },
  364. {
  365. minWidth: 120,
  366. prop: 'clientCode',
  367. label: this.relationType == 1 ? '客户代号' : '供应商代号',
  368. showOverflowTooltip: true,
  369. align: 'center'
  370. },
  371. {
  372. minWidth: 120,
  373. prop: 'engrave',
  374. label: '刻码',
  375. showOverflowTooltip: true,
  376. align: 'center'
  377. },
  378. // {
  379. // minWidth: 160,
  380. // prop: 'packageNo',
  381. // align: 'center',
  382. // label: '包装编码',
  383. // showOverflowTooltip: true
  384. // },
  385. // {
  386. // minWidth: 100,
  387. // prop: 'packingQuantity',
  388. // align: 'center',
  389. // label: '包装数量',
  390. // showOverflowTooltip: true
  391. // },
  392. // {
  393. // minWidth: 120,
  394. // prop: 'packingUnit',
  395. // align: 'center',
  396. // label: '包装单位',
  397. // showOverflowTooltip: true
  398. // },
  399. {
  400. minWidth: 150,
  401. prop: 'measuringUnit',
  402. label: '计量单位',
  403. showOverflowTooltip: true,
  404. align: 'center'
  405. },
  406. {
  407. minWidth: 120,
  408. prop: 'modelKey',
  409. label: '机型',
  410. showOverflowTooltip: true,
  411. align: 'center'
  412. },
  413. {
  414. minWidth: 120,
  415. prop: 'colorKey',
  416. showOverflowTooltip: true,
  417. label: '颜色',
  418. align: 'center'
  419. },
  420. {
  421. width: 220,
  422. prop: 'describes',
  423. label: '描述',
  424. slot: 'describes',
  425. align: 'center'
  426. },
  427. {
  428. columnKey: 'action',
  429. label: '操作',
  430. width: 120,
  431. align: 'center',
  432. resizable: false,
  433. slot: 'action',
  434. fixed: 'right',
  435. showOverflowTooltip: true
  436. }
  437. ];
  438. },
  439. options() {
  440. return this.relationType == 1
  441. ? [
  442. { label: '退货入库', value: 1 },
  443. { label: '返工返修', value: 2 },
  444. { label: '报损', value: 3 },
  445. { label: '报废', value: 4 }
  446. ]
  447. : [
  448. { label: '退货出库', value: 1 },
  449. { label: '返工返修', value: 2 },
  450. { label: '报损', value: 3 },
  451. { label: '报废', value: 4 }
  452. ];
  453. },
  454. options1() {
  455. return this.relationType == 1
  456. ? [
  457. { label: '多发', value: 1 },
  458. { label: '少发', value: 2 },
  459. { label: '错发', value: 3 },
  460. { label: '损坏', value: 4 }
  461. ]
  462. : [
  463. { label: '多收', value: 1 },
  464. { label: '少收', value: 2 },
  465. { label: '错收', value: 3 },
  466. { label: '损坏', value: 4 }
  467. ];
  468. }
  469. },
  470. methods: {
  471. openDialog() {
  472. let ref =
  473. this.relationType == 1
  474. ? 'sendConfirmDialogRef'
  475. : 'receiveTListDialogRef';
  476. this.$refs[ref].open();
  477. },
  478. //打开新增编辑弹框
  479. async open(type, row) {
  480. this.title = type == 'edit' ? '处置' : type == 'add' ? '新建' : '详情';
  481. this.addOrEditDialogFlag = true;
  482. console.log(row);
  483. if (row && row?.id) {
  484. await this.getById(row?.id);
  485. } else {
  486. this.form.relationType = this.relationType;
  487. this.form.relationTypeName = relationTypeOption[this.relationType];
  488. }
  489. },
  490. async changeParent(data) {
  491. console.log('data~~~~~~', this.relationType, data);
  492. if (this.relationType == 1) {
  493. const res = await getSendSaleOrderConfirmDetail(data.id);
  494. this.form.relationCode = res.docNo;
  495. this.form.relationId = res.id;
  496. this.form.relationName = res.contactName + '-' + res.docNo;
  497. this.$set(this.form, 'detailList', res.productList);
  498. }
  499. if (this.relationType == 2) {
  500. const res = await getReceiveConfirmDetail(data.id);
  501. this.form.relationCode = res.receiveConfirmNo;
  502. this.form.relationId = res.id;
  503. res.productList = res.productList.map((item) => {
  504. item['clientCode'] = item.supplierMark;
  505. return item;
  506. });
  507. this.form.relationName = res.supplierName + '-' + res.receiveConfirmNo;
  508. this.$set(this.form, 'detailList', res.productList);
  509. }
  510. },
  511. //获取订单详情
  512. async getById(id) {
  513. this.loading = true;
  514. let data = await getById(id);
  515. data['relationTypeName'] = relationTypeOption[data.relationType];
  516. this.loading = false;
  517. if (data) {
  518. this.form = data;
  519. }
  520. },
  521. getValidate() {
  522. return Promise.all([
  523. new Promise((resolve, reject) => {
  524. this.$refs.form.validate((valid) => {
  525. if (!valid) {
  526. reject(false);
  527. } else {
  528. resolve(true);
  529. }
  530. });
  531. })
  532. ]).catch((e) => {
  533. this.$message.warning('有必填项未填写,请检查');
  534. return Promise.reject(e);
  535. });
  536. },
  537. async save(type) {
  538. try {
  539. await this.getValidate();
  540. this.loading = true;
  541. let isExceptionDispose = false;
  542. let isExceptionDetermine = false;
  543. this.form.formCreateUserId = this.currentUser.currentRoleId;
  544. this.form.detailList.forEach((item) => {
  545. if (!item.exceptionDispose) {
  546. isExceptionDispose = true;
  547. }
  548. if (!item.exceptionDetermine) {
  549. isExceptionDetermine = true;
  550. }
  551. });
  552. if (isExceptionDispose) {
  553. this.$message.error('处置方式不能为空');
  554. return;
  555. }
  556. if (isExceptionDetermine) {
  557. this.$message.error('异常类型不能为空');
  558. return;
  559. }
  560. let api = this.form.id ? update : save;
  561. api(this.form)
  562. .then((res) => {
  563. this.loading = false;
  564. this.businessId = res;
  565. console.log(this.businessId);
  566. this.$message.success('操作成功');
  567. if (type === 'sub') {
  568. this.submit(res);
  569. return;
  570. }
  571. this.cancel();
  572. })
  573. .catch((e) => {
  574. this.loading = false;
  575. });
  576. } catch (error) {
  577. console.log(error);
  578. // 表单验证未通过,不执行保存操作
  579. }
  580. },
  581. remove(index) {
  582. this.form.detailList.splice(index, 1);
  583. },
  584. async submit() {
  585. this.processSubmitDialogFlag = true;
  586. this.$nextTick(() => {
  587. console.log(this.businessId);
  588. let params = {
  589. businessId: this.form.id || this.businessId || '',
  590. businessKey: 'eom_exception_approve',
  591. formCreateUserId:
  592. this.form.createUserId || this.currentUser?.currentRoleId || '',
  593. variables: {
  594. businessCode: this.form.code,
  595. businessName: this.form.name,
  596. businessType: this.form.relationName
  597. }
  598. };
  599. this.$refs.processSubmitDialogRef.init(params);
  600. });
  601. },
  602. reload() {
  603. this.cancel();
  604. },
  605. cancel() {
  606. this.form = {
  607. ...def
  608. };
  609. this.addOrEditDialogFlag = false;
  610. this.$emit('done');
  611. }
  612. }
  613. };
  614. </script>
  615. <style scoped lang="scss">
  616. .TotalAmount {
  617. font-size: 16px;
  618. padding-right: 30px;
  619. }
  620. .headbox {
  621. display: flex;
  622. justify-content: flex-start;
  623. align-items: center;
  624. .amount {
  625. font-size: 14px;
  626. font-weight: bold;
  627. margin-right: 20px;
  628. }
  629. }
  630. </style>