addOrEditDialog.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. const def = {
  214. name: '',
  215. relationCode: '',
  216. relationType: '',
  217. relationName: '',
  218. relationTypeName: '',
  219. relationId: '',
  220. detailList: []
  221. };
  222. export default {
  223. mixins: [dictMixins],
  224. components: {
  225. processSubmitDialog,
  226. bpmDetail,
  227. sendConfirmDialog,
  228. receiveTListDialog
  229. },
  230. props: {
  231. relationType: {
  232. default: 1
  233. }
  234. },
  235. created() {
  236. },
  237. data() {
  238. return {
  239. activeComp: 'main',
  240. tabOptions: [
  241. { key: 'main', name: '处置详情' },
  242. { key: 'bpm', name: '流程详情' }
  243. ],
  244. title: '',
  245. addOrEditDialogFlag: false,
  246. fullscreen: false,
  247. processSubmitDialogFlag: false,
  248. options: [
  249. { label: '退货出库', value: 1 },
  250. { label: '返工返修', value: 2 },
  251. { label: '报损', value: 3 },
  252. { label: '报废', value: 4 }
  253. ],
  254. rules: {
  255. name: [{ required: true, message: '请输入名称', trigger: 'change' }],
  256. relationCode: [
  257. { required: true, message: '请选择来源', trigger: 'change' }
  258. ]
  259. },
  260. form: { ...def }
  261. };
  262. },
  263. computed: {
  264. columns() {
  265. return [
  266. {
  267. width: 45,
  268. type: 'index',
  269. columnKey: 'index',
  270. align: 'center',
  271. fixed: 'left'
  272. },
  273. {
  274. width: 220,
  275. prop: 'exceptionDetermine',
  276. label: '异常类型',
  277. slot: 'exceptionDetermine',
  278. fixed: 'left',
  279. align: 'center',
  280. headerSlot: 'headerExceptionDispose'
  281. },
  282. {
  283. width: 220,
  284. prop: 'exceptionDispose',
  285. label: '处置方式',
  286. slot: 'exceptionDispose',
  287. fixed: 'left',
  288. align: 'center',
  289. headerSlot: 'headerExceptionDispose'
  290. },
  291. {
  292. minWidth: 160,
  293. prop: 'productCode',
  294. label: '编码',
  295. showOverflowTooltip: true,
  296. align: 'center'
  297. },
  298. {
  299. minWidth: 120,
  300. prop: 'productName',
  301. label: '名称',
  302. showOverflowTooltip: true,
  303. align: 'center'
  304. },
  305. {
  306. width: 120,
  307. prop: 'specification',
  308. label: '规格',
  309. slot: 'specification',
  310. align: 'center'
  311. },
  312. {
  313. width: 120,
  314. prop: 'modelType',
  315. label: '型号',
  316. slot: 'modelType',
  317. align: 'center'
  318. },
  319. // {
  320. // minWidth: 100,
  321. // prop: 'saleCount',
  322. // label: '发货数量',
  323. // showOverflowTooltip: true,
  324. // align: 'center'
  325. // },
  326. {
  327. minWidth: 100,
  328. prop: 'totalCount',
  329. slot: 'totalCount',
  330. label: '异常数量',
  331. showOverflowTooltip: true,
  332. align: 'center'
  333. },
  334. {
  335. minWidth: 160,
  336. prop: 'batchNo',
  337. label: '批次号',
  338. showOverflowTooltip: true,
  339. slot: 'batchNo',
  340. align: 'center'
  341. },
  342. {
  343. minWidth: 160,
  344. prop: 'barcodes',
  345. label: '发货条码',
  346. showOverflowTooltip: true,
  347. slot: 'barcodes',
  348. align: 'center'
  349. },
  350. {
  351. minWidth: 120,
  352. prop: 'materielDesignation',
  353. label: '物料代号',
  354. showOverflowTooltip: true,
  355. align: 'center'
  356. },
  357. {
  358. minWidth: 120,
  359. prop: 'clientCode',
  360. label: this.relationType == 1 ? '客户代号' : '供应商代号',
  361. showOverflowTooltip: true,
  362. align: 'center'
  363. },
  364. {
  365. minWidth: 120,
  366. prop: 'engrave',
  367. label: '刻码',
  368. showOverflowTooltip: true,
  369. align: 'center'
  370. },
  371. // {
  372. // minWidth: 160,
  373. // prop: 'packageNo',
  374. // align: 'center',
  375. // label: '包装编码',
  376. // showOverflowTooltip: true
  377. // },
  378. // {
  379. // minWidth: 100,
  380. // prop: 'packingQuantity',
  381. // align: 'center',
  382. // label: '包装数量',
  383. // showOverflowTooltip: true
  384. // },
  385. // {
  386. // minWidth: 120,
  387. // prop: 'packingUnit',
  388. // align: 'center',
  389. // label: '包装单位',
  390. // showOverflowTooltip: true
  391. // },
  392. {
  393. minWidth: 150,
  394. prop: 'measuringUnit',
  395. label: '计量单位',
  396. showOverflowTooltip: true,
  397. align: 'center'
  398. },
  399. {
  400. minWidth: 120,
  401. prop: 'modelKey',
  402. label: '机型',
  403. showOverflowTooltip: true,
  404. align: 'center',
  405. },
  406. {
  407. minWidth: 120,
  408. prop: 'colorKey',
  409. showOverflowTooltip: true,
  410. label: '颜色',
  411. align: 'center',
  412. },
  413. {
  414. width: 220,
  415. prop: 'describes',
  416. label: '描述',
  417. slot: 'describes',
  418. align: 'center'
  419. },
  420. {
  421. columnKey: 'action',
  422. label: '操作',
  423. width: 120,
  424. align: 'center',
  425. resizable: false,
  426. slot: 'action',
  427. fixed: 'right',
  428. showOverflowTooltip: true
  429. }
  430. ];
  431. },
  432. options1() {
  433. return this.relationType == 1
  434. ? [
  435. { label: '多发', value: 1 },
  436. { label: '少发', value: 2 },
  437. { label: '错发', value: 3 },
  438. { label: '损坏', value: 4 }
  439. ]
  440. : [
  441. { label: '多收', value: 1 },
  442. { label: '少收', value: 2 },
  443. { label: '错收', value: 3 },
  444. { label: '损坏', value: 4 }
  445. ];
  446. }
  447. },
  448. methods: {
  449. openDialog() {
  450. let ref =
  451. this.relationType == 1
  452. ? 'sendConfirmDialogRef'
  453. : 'receiveTListDialogRef';
  454. this.$refs[ref].open();
  455. },
  456. //打开新增编辑弹框
  457. async open(type, row) {
  458. this.title = type == 'edit' ? '处置' : type == 'add' ? '新建' : '详情';
  459. this.addOrEditDialogFlag = true;
  460. if (row && row?.id) {
  461. await this.getById(row?.id);
  462. } else {
  463. this.form.relationType = this.relationType;
  464. this.form.relationTypeName = relationTypeOption[this.relationType];
  465. }
  466. },
  467. async changeParent(data) {
  468. if (this.relationType == 1) {
  469. const res = await getSendSaleOrderConfirmDetail(data.id);
  470. this.form.relationCode = res.docNo;
  471. this.form.relationId = res.id;
  472. this.form.relationName = res.contactName + '-' + res.docNo;
  473. this.$set(this.form, 'detailList', res.productList);
  474. }
  475. if (this.relationType == 2) {
  476. const res = await getReceiveConfirmDetail(data.id);
  477. this.form.relationCode = res.receiveConfirmNo;
  478. this.form.relationId = res.id;
  479. res.productList = res.productList.map((item) => {
  480. item['clientCode'] = item.supplierMark;
  481. });
  482. this.form.relationName =
  483. res.supplierName + '-' + res.receiveConfirmNo;
  484. this.$set(this.form, 'detailList', res.productList);
  485. }
  486. },
  487. //获取订单详情
  488. async getById(id) {
  489. this.loading = true;
  490. let data = await getById(id);
  491. data['relationTypeName'] = relationTypeOption[data.relationType];
  492. this.loading = false;
  493. if (data) {
  494. this.form = data;
  495. }
  496. },
  497. getValidate() {
  498. return Promise.all([
  499. new Promise((resolve, reject) => {
  500. this.$refs.form.validate((valid) => {
  501. if (!valid) {
  502. reject(false);
  503. } else {
  504. resolve(true);
  505. }
  506. });
  507. })
  508. ]).catch((e) => {
  509. this.$message.warning('有必填项未填写,请检查');
  510. return Promise.reject(e);
  511. });
  512. },
  513. async save(type) {
  514. try {
  515. await this.getValidate();
  516. this.loading = true;
  517. let isExceptionDispose = false;
  518. let isExceptionDetermine = false;
  519. this.form.detailList.forEach((item) => {
  520. if (!item.exceptionDispose) {
  521. isExceptionDispose = true;
  522. }
  523. if (!item.exceptionDetermine) {
  524. isExceptionDetermine = true;
  525. }
  526. });
  527. if (isExceptionDispose) {
  528. this.$message.error('处置方式不能为空');
  529. return;
  530. }
  531. if (isExceptionDetermine) {
  532. this.$message.error('异常类型不能为空');
  533. return;
  534. }
  535. let api = this.form.id ? update : save;
  536. api(this.form)
  537. .then((res) => {
  538. this.loading = false;
  539. this.$message.success('操作成功');
  540. if (type === 'sub') {
  541. this.submit(res);
  542. return;
  543. }
  544. this.cancel();
  545. })
  546. .catch((e) => {
  547. this.loading = false;
  548. });
  549. } catch (error) {
  550. console.log(error);
  551. // 表单验证未通过,不执行保存操作
  552. }
  553. },
  554. remove(index) {
  555. this.form.detailList.splice(index, 1);
  556. },
  557. async submit() {
  558. this.processSubmitDialogFlag = true;
  559. this.$nextTick(() => {
  560. let params = {
  561. businessId: this.form.id,
  562. businessKey: 'eom_exception_approve',
  563. formCreateUserId: this.form.createUserId,
  564. variables: {
  565. businessCode: this.form.code,
  566. businessName: this.form.name,
  567. businessType: this.form.relationName
  568. }
  569. };
  570. this.$refs.processSubmitDialogRef.init(params);
  571. });
  572. },
  573. reload() {
  574. this.cancel();
  575. },
  576. cancel() {
  577. this.form = {
  578. ...def
  579. };
  580. this.addOrEditDialogFlag = false;
  581. this.$emit('done');
  582. }
  583. }
  584. };
  585. </script>
  586. <style scoped lang="scss">
  587. .TotalAmount {
  588. font-size: 16px;
  589. padding-right: 30px;
  590. }
  591. .headbox {
  592. display: flex;
  593. justify-content: flex-start;
  594. align-items: center;
  595. .amount {
  596. font-size: 14px;
  597. font-weight: bold;
  598. margin-right: 20px;
  599. }
  600. }
  601. </style>