detail.vue 33 KB

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