detail.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. <template>
  2. <div class="borderless" v-loading="pageLoading">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. :loading="btnLoading"
  11. >返回列表</el-button>
  12. </div>
  13. <div class="add-customer-btn">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. class="el-button--small-yh"
  18. @click.stop="openEdit"
  19. v-if="disabled"
  20. >编 辑</el-button>
  21. <el-button
  22. v-if="checker && form.status != 3"
  23. type="primary"
  24. size="small"
  25. class="el-button--small-yh"
  26. @click.stop="openCheckDialog">
  27. 审批
  28. </el-button>
  29. <el-button
  30. v-if="form.status > 0"
  31. @click.native="checkScheduleDialog = true,checkId=form.id"
  32. type="primary"
  33. size="small"
  34. >审核进度</el-button>
  35. <el-button
  36. v-if="confirmDisabled"
  37. :disabled="disabled"
  38. size="small"
  39. type="primary"
  40. @click="repealAllot"
  41. :loading="btnLoading"
  42. >撤销调拨</el-button>
  43. <el-button
  44. v-if="!confirmDisabled"
  45. :disabled="!form.id || disabled"
  46. size="small"
  47. type="primary"
  48. @click="confirmAllot"
  49. :loading="btnLoading"
  50. >确认调拨</el-button>
  51. <el-button
  52. type="success"
  53. :disabled="!form.id"
  54. size="small"
  55. @click="copyDoc"
  56. :loading="btnLoading"
  57. v-if="false"
  58. >复制单据</el-button>
  59. <el-button
  60. type="primary"
  61. @click="editCustomer"
  62. size="small"
  63. :loading="btnLoading"
  64. >保存数据</el-button>
  65. </div>
  66. </div>
  67. <div class="customer-main">
  68. <containerTitle title="基础信息"/>
  69. <basic-container :showBtn="true">
  70. <avue-form
  71. ref="form"
  72. class="trading-form"
  73. v-model="form"
  74. :option="option"
  75. >
  76. <template slot="freightUser">
  77. <el-select
  78. v-model="form.freightUser"
  79. filterable
  80. clearable
  81. size="small"
  82. placeholder="请选择"
  83. :disabled="disabled || confirmDisabled"
  84. >
  85. <el-option
  86. v-for="(item,index) in userList"
  87. :key="index"
  88. :label="item.realName"
  89. :value="item.realName"
  90. ></el-option>
  91. </el-select>
  92. </template>
  93. <template slot="createUser">
  94. <el-select
  95. v-model="form.createUser"
  96. filterable
  97. clearable
  98. size="small"
  99. placeholder="请选择"
  100. disabled
  101. >
  102. <el-option
  103. v-for="(item,index) in userList"
  104. :key="index"
  105. :label="item.realName"
  106. :value="item.id"
  107. ></el-option>
  108. </el-select>
  109. </template>
  110. <template slot="createDept">
  111. <avue-input-tree
  112. leaf-only
  113. style="width: 100%;"
  114. size="small"
  115. :props="{ label: 'title' }"
  116. v-model="form.createDept"
  117. placeholder=" "
  118. type="tree"
  119. :dic="dic"
  120. :nodeClick="deptClick"
  121. disabled=""
  122. ></avue-input-tree>
  123. </template>
  124. <template slot="storageId">
  125. <warehouse-select
  126. v-model="form.storageId"
  127. :configuration="configurationWarehouse"
  128. :disabled="disabled || confirmDisabled"
  129. />
  130. </template>
  131. <template slot="allotStorageId">
  132. <warehouse-select
  133. v-model="form.allotStorageId"
  134. :configuration="configurationWarehouse"
  135. :disabled="disabled || confirmDisabled"
  136. />
  137. </template>
  138. </avue-form>
  139. </basic-container>
  140. <containerTitle title="商品信息"/>
  141. <basic-container>
  142. <avue-crud
  143. ref="crud"
  144. :data="dataList"
  145. :option="tableOption"
  146. :cell-style="cellStyle"
  147. @saveColumn="saveColumn"
  148. @resetColumn="resetColumn"
  149. >
  150. <template slot="menuLeft">
  151. <el-button
  152. type="primary"
  153. icon="el-icon-plus"
  154. size="small"
  155. @click.stop="newDetails"
  156. :disabled="disabled || confirmDisabled"
  157. >录入明细</el-button>
  158. <el-button
  159. type="info"
  160. icon="el-icon-printer"
  161. size="small"
  162. @click="openReport"
  163. >报表打印</el-button>
  164. </template>
  165. <template slot="menu" slot-scope="{ row, index }">
  166. <el-button
  167. size="small"
  168. icon="el-icon-edit"
  169. type="text"
  170. @click="rowCell(row, index)"
  171. :disabled="disabled || confirmDisabled"
  172. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
  173. <el-button
  174. size="small"
  175. icon="el-icon-delete"
  176. type="text"
  177. @click="rowDel(row, index)"
  178. :disabled="disabled || confirmDisabled"
  179. >删除</el-button>
  180. </template>
  181. <template slot="code" slot-scope="{ row, index }">
  182. <span v-if="row.$cellEdit" style="display:flex">
  183. <el-select
  184. v-model="row.code"
  185. placeholder="请选择"
  186. filterable
  187. size="small"
  188. style="width:60%"
  189. @change="codeChange(row, index)"
  190. >
  191. <el-option
  192. v-for="item in goodsoptions"
  193. :key="item.id"
  194. :label="item.code"
  195. :value="item.code"
  196. >
  197. </el-option>
  198. </el-select>
  199. <el-button
  200. icon="el-icon-search"
  201. size="small"
  202. @click="rePick(row, index)"
  203. ></el-button>
  204. </span>
  205. <span v-else> {{ row.code }}</span>
  206. </template>
  207. <template slot="cname" slot-scope="{ row, index }">
  208. <span v-if="row.$cellEdit" style="display:flex">
  209. <el-select
  210. v-model="row.itemId"
  211. placeholder="请选择"
  212. size="small"
  213. filterable
  214. style="width:60%"
  215. @change="cnameChange(row, index)"
  216. >
  217. <el-option
  218. v-for="item in goodsoptions"
  219. :key="item.id"
  220. :label="item.cname"
  221. :value="item.id"
  222. >
  223. </el-option>
  224. </el-select>
  225. <el-button
  226. icon="el-icon-search"
  227. size="small"
  228. @click="rePick(row, index)"
  229. ></el-button>
  230. </span>
  231. <span v-else> {{ row.cname }}</span>
  232. </template>
  233. <template slot="actualQuantity" slot-scope="{ row, index }">
  234. <el-input-number
  235. v-if="row.$cellEdit"
  236. v-model="row.actualQuantity"
  237. size="small"
  238. :controls="false"
  239. :precision="0"
  240. style="width: 100%"
  241. @change="actualQuantityChange(row)"
  242. />
  243. <span v-else>{{ row.actualQuantity | IntegerFormat }}</span>
  244. </template>
  245. <template slot="deliveryAmount" slot-scope="{ row, index }">
  246. <el-input-number
  247. v-if="row.$cellEdit"
  248. v-model="row.deliveryAmount"
  249. size="small"
  250. :controls="false"
  251. :precision="2"
  252. style="width: 100%"
  253. />
  254. <span v-else>{{ row.deliveryAmount | decimalFormat }}</span>
  255. </template>
  256. </avue-crud>
  257. </basic-container>
  258. </div>
  259. <el-dialog
  260. append-to-body
  261. title="审批"
  262. class="el-dialogDeep"
  263. :visible.sync="checkDialog"
  264. width="50%"
  265. :close-on-click-modal="false"
  266. :destroy-on-close="true"
  267. :close-on-press-escape="false"
  268. v-dialog-drag
  269. >
  270. <check
  271. :checkData="checkData"
  272. :checkDetail="false"
  273. :idList="[]"
  274. @choceCheckFun="choceCheckFun"
  275. >
  276. </check>
  277. </el-dialog>
  278. <el-dialog
  279. append-to-body
  280. title="审批进度"
  281. class="el-dialogDeep"
  282. :visible.sync="checkScheduleDialog"
  283. width="40%"
  284. :close-on-click-modal="false"
  285. :destroy-on-close="true"
  286. :close-on-press-escape="false"
  287. v-dialog-drag
  288. >
  289. <check-schedule
  290. :checkId="checkId"
  291. :batchNo="batchNo"
  292. @choceScheduleFun="choceScheduleFun"
  293. >
  294. </check-schedule>
  295. </el-dialog>
  296. <!-- 报表-->
  297. <report-dialog
  298. :switchDialog="switchDialog"
  299. :reportId="form.id"
  300. reportName=""
  301. @onClose="onClose()"
  302. />
  303. <!-- 商品弹窗-->
  304. <el-dialog
  305. title="导入商品"
  306. append-to-body
  307. class="el-dialogDeep"
  308. :visible.sync="dialogVisible"
  309. width="80%"
  310. :close-on-click-modal="false"
  311. :destroy-on-close="true"
  312. :close-on-press-escape="false"
  313. @close="closeGoods"
  314. top="5vh"
  315. v-dialog-drag
  316. >
  317. <span>
  318. <el-row>
  319. <el-col :span="4">
  320. <div>
  321. <el-scrollbar>
  322. <basic-container>
  323. <avue-tree
  324. :option="treeOption"
  325. @node-click="nodeClick"
  326. :style="treeStyle"
  327. />
  328. </basic-container>
  329. </el-scrollbar>
  330. </div>
  331. </el-col>
  332. <el-col :span="20">
  333. <avue-crud
  334. :option="goodsOption"
  335. :table-loading="loading"
  336. :data="goodsListShow"
  337. ref="goodsCrud"
  338. :search.sync="search"
  339. @search-change="searchChange"
  340. @selection-change="selectionChange"
  341. @row-click="rowClick"
  342. :page.sync="page"
  343. @on-load="onLoad"
  344. @saveColumn="saveGoodsColumn"
  345. @resetColumn="resetGoodsColumn"
  346. :cell-style="cellStyle"
  347. >
  348. <template slot="menuLeft">
  349. <el-tabs v-model="activeName" @tab-click="tabHandle">
  350. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  351. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  352. </el-tabs>
  353. </template>
  354. <template slot-scope="scope" slot="menu">
  355. <el-button
  356. type="text"
  357. icon="el-icon-edit"
  358. size="small"
  359. @click.stop="importStagList(scope.row,scope.index)"
  360. v-if="activeName=='searchList'"
  361. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
  362. >选择
  363. </el-button>
  364. <el-button
  365. type="text"
  366. icon="el-icon-delete"
  367. size="small"
  368. @click.stop="removeStagList(scope.row,scope.index)"
  369. v-else
  370. >移除
  371. </el-button>
  372. </template>
  373. </avue-crud>
  374. </el-col>
  375. </el-row>
  376. </span>
  377. <span slot="footer" class="dialog-footer">
  378. <el-button @click="dialogVisible = false">取 消</el-button>
  379. <el-button
  380. type="primary"
  381. @click="importGoods"
  382. :disabled="selectionList.length == 0 && goodsListSave.length == 0"
  383. >导入</el-button
  384. >
  385. </span>
  386. </el-dialog>
  387. </div>
  388. </template>
  389. <script>
  390. import tableOption from "./config/customerContact.json";
  391. import goodsOption from "./config/commodity.json";
  392. import {
  393. isDiscount,
  394. isPercentage,
  395. micrometerFormat,
  396. IntegerFormat
  397. } from "@/util/validate";
  398. import { gainUser } from "@/api/basicData/customerInquiry";
  399. import {getUserInfo} from "@/api/system/user";
  400. import {getDeptTree} from "@/api/system/dept";
  401. import { getCurrentDate } from "@/util/date";
  402. import {dataDetail, typeSave, removeGoods, confirmAllot, repealAllot} from "@/api/dealer/allocation";
  403. import { contrastObj, contrastList } from "@/util/contrastData";
  404. import check from "@/components/check/check";
  405. import checkSchedule from "@/components/check/checkSchedule";
  406. import reportDialog from "@/components/report-dialog/main";
  407. import {getDeptLazyTree,
  408. getGoods,} from "@/api/basicData/customerInquiry";
  409. import {selectGoodsNum} from "@/api/basicData/inventoryAccount";
  410. export default {
  411. name: "detail",
  412. props: {
  413. detailData: {
  414. type: Object
  415. }
  416. },
  417. components: {
  418. check,
  419. checkSchedule,
  420. reportDialog
  421. },
  422. data() {
  423. return {
  424. disabled: false,
  425. pageLoading: false,
  426. btnLoading: false,
  427. form: {
  428. deliveryStatus: '录入'
  429. },
  430. option: {
  431. menuBtn: false,
  432. labelWidth: 100,
  433. column: [
  434. {
  435. label: "原仓库",
  436. prop: "storageId",
  437. rules: [
  438. {
  439. required: true,
  440. message: " ",
  441. trigger: "change"
  442. }
  443. ],
  444. span: 8,
  445. slot: true,
  446. },
  447. {
  448. label: "现仓库",
  449. prop: "allotStorageId",
  450. rules: [
  451. {
  452. required: true,
  453. message: " ",
  454. trigger: "change"
  455. }
  456. ],
  457. span: 8,
  458. slot: true,
  459. },
  460. {
  461. label: "业务日期",
  462. prop: "businessDate",
  463. span: 8,
  464. type: "date",
  465. format: "yyyy-MM-dd",
  466. valueFormat: "yyyy-MM-dd HH:mm:ss",
  467. rules: [
  468. {
  469. required: true,
  470. message: " ",
  471. trigger: "blur"
  472. }
  473. ],
  474. disabled: false
  475. },
  476. {
  477. label: "仓管员",
  478. prop: "freightUser",
  479. rules: [
  480. {
  481. required: true,
  482. message: " ",
  483. trigger: "blur"
  484. }
  485. ],
  486. span: 8,
  487. slot: true,
  488. },
  489. {
  490. label: "制单人",
  491. prop: "createUser",
  492. span: 8,
  493. slot: true,
  494. disabled: true
  495. },
  496. {
  497. label: "制单部门",
  498. prop: "createDept",
  499. span: 8,
  500. slot: true,
  501. disabled: true
  502. },
  503. {
  504. label: "制单日期",
  505. prop: "createTime",
  506. type: "date",
  507. format: "yyyy-MM-dd HH:mm:ss",
  508. valueFormat: "yyyy-MM-dd HH:mm:ss",
  509. span: 8,
  510. slot: true,
  511. disabled: true
  512. },
  513. {
  514. label: "系统编号",
  515. prop: "sysNo",
  516. span: 8,
  517. slot: true,
  518. disabled: true,
  519. },
  520. {
  521. label: "单据状态",
  522. prop: "deliveryStatus",
  523. span: 8,
  524. slot: true,
  525. disabled: true,
  526. },
  527. {
  528. label: "备注",
  529. prop: "remarks",
  530. type: "textarea",
  531. minRows: 2,
  532. span: 24,
  533. },
  534. ],
  535. },
  536. dataList: [],
  537. tableOption: {},
  538. goodsoptions: [],
  539. unitOption: [],
  540. selectionList: [],
  541. treeDeptId: null,
  542. reData: null,
  543. treeOption: {
  544. nodeKey: "id",
  545. lazy: true,
  546. treeLoad: function(node, resolve) {
  547. const parentId = node.level === 0 ? 0 : node.data.id;
  548. getDeptLazyTree(parentId).then(res => {
  549. resolve(
  550. res.data.data.map(item => {
  551. return {
  552. ...item,
  553. leaf: !item.hasChildren
  554. };
  555. })
  556. );
  557. });
  558. },
  559. addBtn: false,
  560. menu: false,
  561. size: "small",
  562. props: {
  563. label: "title",
  564. value: "value",
  565. children: "children"
  566. }
  567. },
  568. search: {},
  569. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  570. goodsOption: {},
  571. loading: false,
  572. switchDialog: false, // 报表弹窗控制
  573. userList: [],
  574. dic: [], // 部门
  575. loginUser: '', // 登录人
  576. // 仓库配置
  577. configurationWarehouse: {
  578. multipleChoices: false,
  579. multiple: false,
  580. collapseTags: false,
  581. placeholder: "请点击右边按钮选择",
  582. dicData: [],
  583. },
  584. oldForm: {},
  585. oldDataList: [],
  586. checker: false,
  587. checkId: '',
  588. batchNo:'',
  589. checkDialog: false,
  590. checkScheduleDialog: false,
  591. checkData: {},
  592. dialogVisible: false,
  593. activeName: 'searchList',
  594. // 商品列表数据合计
  595. goodsListShow: [],
  596. // 商品列表暂存
  597. goodsListSave: [],
  598. page: {
  599. pageSize: 10,
  600. currentPage: 1,
  601. total: 0
  602. },
  603. pageList: {
  604. pageSize: 10,
  605. currentPage: 1,
  606. total: 0
  607. },
  608. confirmDisabled: false, // 调拨状态禁用
  609. }
  610. },
  611. async created() {
  612. this.$set(this.form, 'businessDate', getCurrentDate()); // 默认当前日期
  613. this.$set(this.form, 'createTime', getCurrentDate());
  614. this.tableOption = await this.getColumnData(
  615. this.getColumnName(122),
  616. tableOption
  617. );
  618. this.goodsOption = await this.getColumnData(
  619. this.getColumnName(123),
  620. goodsOption
  621. );
  622. gainUser().then(res => {
  623. this.userList = res.data.data;
  624. });
  625. getDeptTree().then(res => {
  626. this.dic = res.data.data
  627. })
  628. getGoods(1, 10).then(res => {
  629. if (res.data.data.total > 0) {
  630. this.goodsoptions = res.data.data.records;
  631. if (Math.ceil(res.data.data.total / 10) > 1) {
  632. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  633. getGoods(i, 10).then(e => {
  634. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  635. });
  636. }
  637. }
  638. }
  639. });
  640. this.getWorkDicts('unit').then(res => {
  641. this.unitOption = res.data.data;
  642. })
  643. if (this.detailData.query) {
  644. this.disabled = true;
  645. this.option.column.map(e => {
  646. this.$set(e, 'disabled', true)
  647. })
  648. this.queryData(this.detailData.id);
  649. } else if (this.detailData.auditId) {
  650. this.checker = true;
  651. this.batchNo = this.detailData.check.batchNo
  652. this.queryData(this.detailData.id);
  653. } else {
  654. getUserInfo().then(res => {
  655. this.$set(this.form, 'createUser', res.data.data.id);
  656. // this.$set(this.form, 'userName', res.data.data.realName);
  657. this.$set(this.form, 'createDept', res.data.data.deptId);
  658. // this.$set(this.form, 'deptName', res.data.data.deptName);
  659. // this.$set(this.form, 'postId', res.data.data.postId.split(',')[0]);
  660. // this.$set(this.form, 'postName', res.data.data.postName.split(',')[0]);
  661. this.loginUser = res.data.data.realName;
  662. this.oldForm = this.deepClone(this.form);
  663. this.oldDataList = this.deepClone(this.dataList);
  664. })
  665. }
  666. },
  667. filters: {
  668. IntegerFormat(num) {
  669. return IntegerFormat(num);
  670. },
  671. decimalFormat(num) {
  672. return num ? Number(num).toFixed(2) : "0.00";
  673. }
  674. },
  675. methods: {
  676. // 查询
  677. queryData(id) {
  678. this.pageLoading = true;
  679. dataDetail(id).then(res => {
  680. this.$set(this,'form',res.data.data)
  681. this.confirmDisabled = this.form.deliveryStatus === '确认调拨'? true: false;
  682. this.dataList = this.form.deliveryItemsList? this.form.deliveryItemsList: [];
  683. this.oldForm = this.deepClone(this.form);
  684. this.oldDataList = this.deepClone(this.dataList);
  685. }).finally(() => {
  686. this.pageLoading = false;
  687. })
  688. },
  689. //返回列表
  690. backToList() {
  691. if (this.verification()) {
  692. this.$emit("goBack");
  693. }
  694. },
  695. // 编辑按钮触发
  696. openEdit() {
  697. this.disabled = false;
  698. this.option.column.map(e => {
  699. if (!this.confirmDisabled) {
  700. if (e.prop != 'sysNo' && e.prop != 'createTime' && e.prop != 'deliveryStatus') {
  701. this.$set(e, 'disabled', false);
  702. }
  703. } else {
  704. this.$set(e, 'disabled', true);
  705. }
  706. })
  707. },
  708. // 复制
  709. copyDoc() {
  710. this.$emit("copyOrder", this.form.id);
  711. },
  712. //修改提交触发
  713. editCustomer(status) {
  714. this.$refs["form"].validate((valid, done) => {
  715. done();
  716. if (valid) {
  717. if (this.form.storageId == this.form.allotStorageId) {
  718. return this.$message.error('原仓库与现仓库不能一致')
  719. }
  720. let totalQuantity = 0; //总数量
  721. let deliveryAmount = 0; //总金额
  722. this.dataList.forEach(item => {
  723. deliveryAmount += Number(item.deliveryAmount);
  724. totalQuantity += Number(item.actualQuantity);
  725. })
  726. this.$set(this.form, 'deliveryAmount', deliveryAmount);
  727. this.$set(this.form, 'totalQuantity', totalQuantity);
  728. this.$set(this.form, 'deliveryItemsList', this.dataList)
  729. this.btnLoading = true;
  730. typeSave(this.form).then(res => {
  731. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  732. this.queryData(res.data.data.id);
  733. }).finally(() => {
  734. this.btnLoading = false;
  735. })
  736. } else {
  737. return false
  738. }
  739. })
  740. },
  741. cellStyle() {
  742. return "padding:0;height:40px;";
  743. },
  744. async saveColumn() {
  745. const inSave = await this.saveColumnData(
  746. this.getColumnName(122),
  747. this.tableOption
  748. );
  749. if (inSave) {
  750. this.$message.success("保存成功");
  751. //关闭窗口
  752. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  753. this.$nextTick(() => {
  754. this.$refs.crud.doLayout()
  755. })
  756. }
  757. },
  758. async resetColumn() {
  759. this.tableOption = tableOption;
  760. const inSave = await this.delColumnData(
  761. this.getColumnName(122),
  762. tableOption
  763. );
  764. if (inSave) {
  765. this.$nextTick(() => {
  766. this.$refs.crud.doLayout()
  767. })
  768. this.$message.success("重置成功");
  769. //关闭窗口
  770. setTimeout(() => {
  771. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  772. }, 1000);
  773. }
  774. },
  775. //录入明细
  776. newDetails() {
  777. this.$refs["form"].validate((valid, done) => {
  778. done()
  779. if (valid) {
  780. this.dialogVisible = !this.dialogVisible;
  781. }
  782. })
  783. },
  784. rowCell(row, index) {
  785. if (row.$cellEdit == true) {
  786. this.$set(row, "$cellEdit", false);
  787. } else {
  788. this.$set(row, "$cellEdit", true);
  789. }
  790. },
  791. rowDel(row, index) {
  792. this.$confirm("确定删除数据?", {
  793. confirmButtonText: "确定",
  794. cancelButtonText: "取消",
  795. type: "warning"
  796. }).then(() => {
  797. if (row.id) {
  798. removeGoods(row.id).then(res => {
  799. this.$message({
  800. type: 'success',
  801. message: '删除成功!'
  802. })
  803. this.dataList.splice(row.$index, 1);
  804. })
  805. } else {
  806. this.$message({
  807. type: "success",
  808. message: "删除成功!"
  809. });
  810. this.dataList.splice(row.$index, 1);
  811. }
  812. });
  813. },
  814. getKHData(row) {},
  815. // 验证新旧值对比
  816. verification() {
  817. if (contrastObj(this.form, this.oldForm) ||
  818. contrastList(this.dataList, this.oldDataList)) {
  819. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  820. confirmButtonText: "确定",
  821. cancelButtonText: "取消",
  822. type: "warning"
  823. }).then(() => {
  824. this.editCustomer();
  825. }).catch(() => {
  826. return false; //取消改动数据
  827. })
  828. } else {
  829. return true;
  830. }
  831. },
  832. deptClick(data) {
  833. this.$set(this.form, 'deptName', data.title)
  834. },
  835. //打开审核
  836. openCheckDialog(){
  837. this.checkData = this.detailData.check
  838. this.checkDialog = true;
  839. },
  840. //关闭审核
  841. choceCheckFun(){
  842. this.checkDialog = false;
  843. },
  844. choceScheduleFun(){
  845. this.checkScheduleDialog = false
  846. },
  847. // 报表
  848. openReport() {
  849. this.switchDialog =! this.switchDialog;
  850. },
  851. // 报表关闭
  852. onClose(val) {
  853. this.switchDialog = val;
  854. },
  855. rePick(row, index) {
  856. this.reData = {
  857. ...row,
  858. index: index
  859. };
  860. this.newDetails();
  861. },
  862. codeChange(row) {
  863. this.goodsoptions.forEach(async e => {
  864. if (e.code == row.code) {
  865. await selectGoodsNum({
  866. goodsId: e.id,
  867. tradeType: 'JXS',
  868. storageId: this.form.storageId
  869. }).then(res => {
  870. row.inventoryNumber = res.data.data;
  871. })
  872. row.itemId = e.id;
  873. row.storageQuantity = e.storageQuantity;
  874. row.cname = e.cname;
  875. row.code = e.code;
  876. row.corpId = e.corpId;
  877. row.corpName = e.corpName;
  878. row.brandItem = e.brandItem;
  879. row.specsOne = e.specsOne;
  880. row.specsTwo = e.specsTwo;
  881. row.typeno = e.typeno;
  882. row.unit = e.unit;
  883. row.size = e.size;
  884. row.priceCategory = e.goodsTypeName;
  885. }
  886. });
  887. },
  888. cnameChange(row) {
  889. this.goodsoptions.forEach(async e => {
  890. if (e.id == row.itemId) {
  891. await selectGoodsNum({
  892. goodsId: e.id,
  893. tradeType: 'JXS',
  894. storageId: this.form.storageId
  895. }).then(res => {
  896. row.inventoryNumber = res.data.data;
  897. })
  898. row.storageQuantity = e.storageQuantity
  899. row.cname = e.cname;
  900. row.code = e.code;
  901. row.corpId = e.corpId;
  902. row.corpName = e.corpName;
  903. row.brandItem = e.brandItem;
  904. row.specsOne = e.specsOne;
  905. row.specsTwo = e.specsTwo;
  906. row.typeno = e.typeno;
  907. row.unit = e.unit;
  908. row.size = e.size;
  909. row.priceCategory = e.goodsTypeName;
  910. }
  911. });
  912. },
  913. importGoods() {
  914. if (this.reData) {
  915. if (this.selectionList.length != 1) {
  916. return this.$message.error("重新选择的时候只能选择一条数据");
  917. } else {
  918. this.selectionList.forEach(e => {
  919. this.dataList.forEach(async (item, index) => {
  920. await selectGoodsNum({
  921. goodsId: e.id,
  922. tradeType: 'JXS',
  923. storageId: this.form.storageId
  924. }).then(res => {
  925. e.inventoryNumber = res.data.data;
  926. })
  927. if (index == this.reData.index) {
  928. item.itemId = e.id;
  929. item.code = e.code;
  930. item.cname = e.cname;
  931. item.corpId = e.corpId;
  932. item.corpName = e.corpName;
  933. item.brandItem = e.brandItem;
  934. item.specsOne = e.specsOne;
  935. item.specsTwo = e.specsTwo;
  936. item.typeno = e.typeno;
  937. item.unit = e.unit;
  938. item.size = e.size;
  939. item.priceCategory = e.goodsTypeName;
  940. item.inventoryNumber = e.inventoryNumber;
  941. item.$cellEdit = true;
  942. }
  943. });
  944. });
  945. }
  946. } else {
  947. if (this.goodsListSave.length > 0) { // 暂存的有数据
  948. this.goodsListSave.forEach(async e => {
  949. await selectGoodsNum({
  950. goodsId: e.id,
  951. tradeType: 'JXS',
  952. storageId: this.form.storageId
  953. }).then(res => {
  954. e.inventoryNumber = res.data.data;
  955. })
  956. this.dataList.push({
  957. itemId: e.id,
  958. code: e.code,
  959. cname: e.cname,
  960. brandItem: e.brandItem,
  961. specsOne: e.specsOne,
  962. specsTwo: e.specsTwo,
  963. typeno: e.typeno,
  964. corpId: e.corpId,
  965. corpName: e.corpName,
  966. unit: e.unit,
  967. size: e.size,
  968. price: e.price,
  969. deliveryAmount: 0,
  970. actualQuantity: 0,
  971. storageQuantity: e.storageQuantity,
  972. inventoryNumber: e.inventoryNumber,
  973. $cellEdit: true
  974. });
  975. });
  976. } else {
  977. this.selectionList.forEach(async e => {
  978. await selectGoodsNum({
  979. goodsId: e.id,
  980. tradeType: 'JXS',
  981. storageId: this.form.storageId
  982. }).then(res => {
  983. e.inventoryNumber = res.data.data;
  984. })
  985. this.dataList.push({
  986. itemId: e.id,
  987. code: e.code,
  988. cname: e.cname,
  989. brandItem: e.brandItem,
  990. specsOne: e.specsOne,
  991. specsTwo: e.specsTwo,
  992. typeno: e.typeno,
  993. corpId: e.corpId,
  994. corpName: e.corpName,
  995. unit: e.unit,
  996. size: e.size,
  997. deliveryAmount: 0,
  998. actualQuantity: 0,
  999. inventoryNumber: e.inventoryNumber,
  1000. $cellEdit: true
  1001. });
  1002. });
  1003. }
  1004. }
  1005. this.dialogVisible = false;
  1006. },
  1007. closeGoods() {
  1008. this.selectionList = [];
  1009. this.treeDeptId = "";
  1010. this.reData = null;
  1011. this.activeName = 'searchList';
  1012. this.goodsListSave = [];
  1013. },
  1014. nodeClick(data) {
  1015. this.treeDeptId = data.id;
  1016. this.page.currentPage = 1;
  1017. this.onLoad(this.page);
  1018. },
  1019. //商品查询
  1020. onLoad(page, params = {}) {
  1021. let obj = this.deepClone(Object.assign(params, this.search));
  1022. this.loading = true;
  1023. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  1024. .then(res => {
  1025. const data = res.data.data;
  1026. this.page.total = data.total;
  1027. this.goodsList = data.records;
  1028. this.pageList.total = data.total;
  1029. this.goodsListShow = data.records;
  1030. if (this.page.total) {
  1031. this.goodsOption.height = window.innerHeight - 350;
  1032. }
  1033. })
  1034. .finally(() => {
  1035. this.loading = false;
  1036. });
  1037. },
  1038. searchChange(params, done) {
  1039. this.search = this.deepClone(params);
  1040. this.onLoad(this.page, params);
  1041. done();
  1042. },
  1043. selectionChange(list) {
  1044. this.selectionList = list;
  1045. },
  1046. rowClick(row) {
  1047. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  1048. },
  1049. async saveGoodsColumn() {
  1050. const inSave = await this.saveColumnData(
  1051. this.getColumnName(123),
  1052. this.goodsOption
  1053. );
  1054. if (inSave) {
  1055. this.$message.success("保存成功");
  1056. //关闭窗口
  1057. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1058. this.$nextTick(() => {
  1059. this.$refs.goodsCrud.doLayout()
  1060. })
  1061. }
  1062. },
  1063. async resetGoodsColumn() {
  1064. this.goodsOption = goodsOption;
  1065. const inSave = await this.delColumnData(
  1066. this.getColumnName(123),
  1067. goodsOption
  1068. );
  1069. if (inSave) {
  1070. this.$nextTick(() => {
  1071. this.$refs.goodsCrud.doLayout()
  1072. })
  1073. this.$message.success("重置成功");
  1074. //关闭窗口
  1075. setTimeout(() => {
  1076. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1077. }, 1000);
  1078. }
  1079. },
  1080. // 标签页切换
  1081. tabHandle(data) {
  1082. if (data.name == 'searchList') {
  1083. this.goodsListShow = this.goodsList;
  1084. this.page.total = this.pageList.total
  1085. } else if (data.name == 'importStaging') {
  1086. this.goodsListShow = this.goodsListSave;
  1087. this.page.total = 0
  1088. }
  1089. },
  1090. removeStagList(row, index) {
  1091. this.goodsListSave.splice(row.$index, 1)
  1092. },
  1093. importStagList(row, index) {
  1094. this.goodsListSave.push(row);
  1095. },
  1096. actualQuantityChange(row) {
  1097. if (Number(row.actualQuantity) > Number(row.inventoryNumber)) {
  1098. this.$set(row, 'actualQuantity', '0');
  1099. this.$message.error('调拨件数不能超过结余库存')
  1100. }
  1101. },
  1102. // 确认调拨
  1103. confirmAllot() {
  1104. if (this.verification()) {
  1105. this.btnLoading = true;
  1106. this.$set(this.form, 'deliveryItemsList', this.dataList);
  1107. confirmAllot(this.form).then(res => {
  1108. this.queryData(this.form.id);
  1109. this.$message.success('调拨成功');
  1110. this.option.column.map(e => {
  1111. this.$set(e, 'disabled', true);
  1112. })
  1113. }).finally(() => {
  1114. this.btnLoading = false;
  1115. })
  1116. }
  1117. },
  1118. // 撤销调拨
  1119. repealAllot() {
  1120. this.btnLoading = true;
  1121. this.$set(this.form, 'deliveryItemsList', this.dataList);
  1122. repealAllot(this.form).then(res => {
  1123. this.queryData(this.form.id);
  1124. this.$message.success('撤销成功');
  1125. this.option.column.map(e => {
  1126. if (e.prop != 'sysNo' && e.prop != 'createTime' && e.prop != 'deliveryStatus') {
  1127. this.$set(e, 'disabled', false);
  1128. }
  1129. })
  1130. }).finally(() => {
  1131. this.btnLoading = false;
  1132. })
  1133. },
  1134. },
  1135. }
  1136. </script>
  1137. <style scoped>
  1138. </style>