detail.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  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. v-if="disabled"
  16. type="primary"
  17. size="small"
  18. class="el-button--small-yh"
  19. @click.stop="openEdit"
  20. >编 辑</el-button>
  21. <el-button
  22. v-if="form.status < 4"
  23. type="primary"
  24. size="small"
  25. icon="el-icon-folder-add"
  26. @click="confirmReceipt"
  27. :loading="btnLoading"
  28. :disabled="disabled"
  29. >确认入库</el-button>
  30. <el-button
  31. v-else
  32. type="primary"
  33. size="small"
  34. icon="el-icon-folder-remove"
  35. @click="cancelReceipt"
  36. :loading="btnLoading"
  37. :disabled="disabled"
  38. >撤销入库</el-button>
  39. <el-button
  40. type="success"
  41. :disabled="!form.id"
  42. size="small"
  43. @click="copyDoc"
  44. :loading="btnLoading"
  45. >复制单据</el-button>
  46. <el-button
  47. type="primary"
  48. @click="editCustomer"
  49. size="small"
  50. :loading="btnLoading"
  51. :disabled="disabled || confirmDisabled"
  52. >保存数据</el-button>
  53. </div>
  54. </div>
  55. <div class="customer-main">
  56. <containerTitle title="基础信息"/>
  57. <basic-container :showBtn="true">
  58. <avue-form
  59. ref="form"
  60. class="trading-form"
  61. v-model="form"
  62. :option="option"
  63. >
  64. <template slot="stockUser">
  65. <el-select
  66. v-model="form.stockUser"
  67. filterable
  68. clearable
  69. size="small"
  70. :disabled="disabled || confirmDisabled"
  71. >
  72. <el-option
  73. v-for="(item,index) in userList"
  74. :key="index"
  75. :label="item.realName"
  76. :value="item.id"
  77. ></el-option>
  78. </el-select>
  79. </template>
  80. <template slot="stockDept">
  81. <avue-input-tree
  82. leaf-only
  83. style="width: 100%;"
  84. size="small"
  85. :props="{ label: 'title' }"
  86. v-model="form.stockDept"
  87. placeholder=" "
  88. type="tree"
  89. :dic="dic"
  90. :disabled="disabled || confirmDisabled"
  91. ></avue-input-tree>
  92. </template>
  93. </avue-form>
  94. </basic-container>
  95. <containerTitle title="商品信息"/>
  96. <basic-container>
  97. <avue-crud
  98. ref="crud"
  99. :data="dataList"
  100. :option="tableOption"
  101. :cell-style="cellStyle"
  102. @saveColumn="saveColumn"
  103. @resetColumn="resetColumn"
  104. >
  105. <template slot="menuLeft">
  106. <el-button
  107. type="primary"
  108. icon="el-icon-plus"
  109. size="small"
  110. @click.stop="newDetails"
  111. :disabled="disabled || confirmDisabled"
  112. >录入明细</el-button>
  113. <el-button
  114. type="info"
  115. icon="el-icon-printer"
  116. size="small"
  117. >报 表</el-button>
  118. </template>
  119. <template slot="menu" slot-scope="{ row, index }">
  120. <el-button
  121. size="small"
  122. icon="el-icon-edit"
  123. type="text"
  124. @click="rowCell(row, index)"
  125. :disabled="disabled || confirmDisabled"
  126. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
  127. <el-button
  128. size="small"
  129. icon="el-icon-delete"
  130. type="text"
  131. @click="rowDel(row, index)"
  132. :disabled="disabled || confirmDisabled"
  133. >删除</el-button>
  134. </template>
  135. <template slot="code" slot-scope="{ row, index }">
  136. <span v-if="row.$cellEdit" style="display:flex">
  137. <el-select
  138. v-model="row.code"
  139. placeholder="请选择"
  140. filterable
  141. size="small"
  142. style="width:60%"
  143. @change="codeChange(row, index)"
  144. >
  145. <el-option
  146. v-for="item in goodsoptions"
  147. :key="item.id"
  148. :label="item.code"
  149. :value="item.code"
  150. >
  151. </el-option>
  152. </el-select>
  153. <el-button
  154. icon="el-icon-search"
  155. size="small"
  156. @click="rePick(row, index)"
  157. ></el-button>
  158. </span>
  159. <span v-else> {{ row.code }}</span>
  160. </template>
  161. <template slot="cname" slot-scope="{ row, index }">
  162. <span v-if="row.$cellEdit" style="display:flex">
  163. <el-select
  164. v-model="row.itemId"
  165. placeholder="请选择"
  166. size="small"
  167. filterable
  168. style="width:60%"
  169. @change="cnameChange(row, index)"
  170. >
  171. <el-option
  172. v-for="item in goodsoptions"
  173. :key="item.id"
  174. :label="item.cname"
  175. :value="item.id"
  176. >
  177. </el-option>
  178. </el-select>
  179. <el-button
  180. icon="el-icon-search"
  181. size="small"
  182. @click="rePick(row, index)"
  183. ></el-button>
  184. </span>
  185. <span v-else> {{ row.cname }}</span>
  186. </template>
  187. <template slot="orderQuantity" slot-scope="{ row, index }">
  188. <el-input-number
  189. v-if="row.$cellEdit"
  190. v-model="row.orderQuantity"
  191. size="small"
  192. :controls="false"
  193. :precision="0"
  194. @input="amountChange(row)"
  195. style="width: 100%"
  196. />
  197. <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
  198. </template>
  199. <template slot="price" slot-scope="{ row, index }">
  200. <el-input-number
  201. v-if="row.$cellEdit"
  202. v-model="row.price"
  203. size="small"
  204. :controls="false"
  205. :precision="2"
  206. @input="amountChange(row)"
  207. style="width: 100%"
  208. ></el-input-number>
  209. <span v-else>{{ row.price }}</span>
  210. </template>
  211. <!-- 单位-->
  212. <template slot="unit" slot-scope="{ row, index }">
  213. <el-select
  214. v-if="row.$cellEdit"
  215. v-model="row.unit"
  216. size="small"
  217. clearable
  218. filterable
  219. >
  220. <el-option
  221. v-for="(item, index) in unitOption"
  222. :key="index"
  223. :label="item.dictValue"
  224. :value="item.dictValue"
  225. />
  226. </el-select>
  227. <span v-else>{{ row.unit }}</span>
  228. </template>
  229. <template slot="amount" slot-scope="{ row, index }">
  230. <span>{{ row.amount | decimalFormat }}</span>
  231. </template>
  232. <template slot="storageQuantity" slot-scope="{ row, index }">
  233. <span>{{ row.storageQuantity | IntegerFormat }}</span>
  234. </template>
  235. <template slot="storageId" slot-scope="{ row, index }">
  236. <el-select
  237. v-if="row.$cellEdit"
  238. v-model="row.storageId"
  239. filterable
  240. clearable
  241. >
  242. <el-option
  243. v-for="(item, index) in storageOptions"
  244. :key="index"
  245. :value="item.id"
  246. :label="item.cname"
  247. ></el-option>
  248. </el-select>
  249. <span v-else>{{ row.storageName }}</span>
  250. </template>
  251. <template slot="remarks" slot-scope="{ row, index }">
  252. <el-input
  253. v-if="row.$cellEdit"
  254. v-model="row.remarks"
  255. size="small"
  256. />
  257. <span v-else>{{ row.remarks }}</span>
  258. </template>
  259. </avue-crud>
  260. </basic-container>
  261. </div>
  262. <!-- 商品弹窗-->
  263. <el-dialog
  264. title="导入商品"
  265. append-to-body
  266. class="el-dialogDeep"
  267. :visible.sync="dialogVisible"
  268. width="80%"
  269. :close-on-click-modal="false"
  270. :destroy-on-close="true"
  271. :close-on-press-escape="false"
  272. @close="closeGoods"
  273. top="5vh"
  274. v-dialog-drag
  275. >
  276. <span>
  277. <el-row>
  278. <el-col :span="4">
  279. <div>
  280. <el-scrollbar>
  281. <basic-container>
  282. <avue-tree
  283. :option="treeOption"
  284. @node-click="nodeClick"
  285. :style="treeStyle"
  286. />
  287. </basic-container>
  288. </el-scrollbar>
  289. </div>
  290. </el-col>
  291. <el-col :span="20">
  292. <avue-crud
  293. :option="goodsOption"
  294. :table-loading="loading"
  295. :data="goodsListShow"
  296. ref="goodsCrud"
  297. :search.sync="search"
  298. @search-change="searchChange"
  299. @selection-change="selectionChange"
  300. @row-click="rowClick"
  301. :page.sync="page"
  302. @on-load="onLoad"
  303. @saveColumn="saveGoodsColumn"
  304. @resetColumn="resetGoodsColumn"
  305. :cell-style="cellStyle"
  306. >
  307. <template slot="menuLeft">
  308. <el-tabs v-model="activeName" @tab-click="tabHandle">
  309. <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
  310. <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
  311. </el-tabs>
  312. </template>
  313. <template slot-scope="scope" slot="menu">
  314. <el-button
  315. type="text"
  316. icon="el-icon-edit"
  317. size="small"
  318. @click.stop="importStagList(scope.row,scope.index)"
  319. v-if="activeName=='searchList'"
  320. :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
  321. >选择
  322. </el-button>
  323. <el-button
  324. type="text"
  325. icon="el-icon-delete"
  326. size="small"
  327. @click.stop="removeStagList(scope.row,scope.index)"
  328. v-else
  329. >移除
  330. </el-button>
  331. </template>
  332. </avue-crud>
  333. </el-col>
  334. </el-row>
  335. </span>
  336. <span slot="footer" class="dialog-footer">
  337. <el-button @click="dialogVisible = false">取 消</el-button>
  338. <el-button
  339. type="primary"
  340. @click="importGoods"
  341. :disabled="selectionList.length == 0 && goodsListSave.length == 0"
  342. >导入</el-button
  343. >
  344. </span>
  345. </el-dialog>
  346. </div>
  347. </template>
  348. <script>
  349. import tableOption from "./config/customerContact.json";
  350. import goodsOption from "./config/commodity.json";
  351. import {getDeptLazyTree,
  352. getGoods,} from "@/api/basicData/customerInquiry";
  353. import {
  354. isDiscount,
  355. isPercentage,
  356. micrometerFormat,
  357. IntegerFormat
  358. } from "@/util/validate";
  359. import { gainUser } from "@/api/basicData/customerInquiry";
  360. import {getUserInfo} from "@/api/system/user";
  361. import {getDeptTree} from "@/api/system/dept";
  362. import { getCurrentDate } from "@/util/date";
  363. import {dataDetail,
  364. typeSave,
  365. removeGoods,
  366. confirmReceipt,
  367. cancelReceipt,} from "@/api/officeSupplies/warehousing";
  368. import { contrastObj, contrastList } from "@/util/contrastData";
  369. import {customerList as storageList} from "@/api/basicData/basicStorageDesc";
  370. export default {
  371. name: "detail",
  372. props: {
  373. detailData: {
  374. type: Object
  375. }
  376. },
  377. data() {
  378. return {
  379. disabled: false,
  380. pageLoading: false,
  381. btnLoading: false,
  382. form: {},
  383. option: {
  384. menuBtn: false,
  385. labelWidth: 100,
  386. column: [
  387. {
  388. label: "库管人",
  389. prop: "stockUser",
  390. rules: [
  391. {
  392. required: true,
  393. message: " ",
  394. trigger: "change"
  395. }
  396. ],
  397. span: 8,
  398. slot: true,
  399. },
  400. {
  401. label: "部门",
  402. prop: "stockDept",
  403. rules: [
  404. {
  405. required: true,
  406. message: " ",
  407. trigger: "change"
  408. }
  409. ],
  410. span: 8,
  411. slot: true,
  412. },
  413. {
  414. label: "入库时间",
  415. prop: "stockTime",
  416. span: 8,
  417. type: "date",
  418. format: "yyyy-MM-dd",
  419. valueFormat: "yyyy-MM-dd 00:00:00",
  420. rules: [
  421. {
  422. required: true,
  423. message: " ",
  424. trigger: "blur"
  425. }
  426. ]
  427. },
  428. {
  429. label: "系统号",
  430. prop: "sysNo",
  431. span: 8,
  432. disabled: true
  433. },
  434. {
  435. label: "备注",
  436. prop: "orderRemark",
  437. type: "textarea",
  438. minRows: 2,
  439. span: 24,
  440. },
  441. ],
  442. },
  443. dataList: [],
  444. tableOption: {},
  445. goodsoptions: [],
  446. unitOption: [],
  447. dialogVisible: false,
  448. selectionList: [],
  449. treeDeptId: null,
  450. reData: null,
  451. treeOption: {
  452. nodeKey: "id",
  453. lazy: true,
  454. treeLoad: function(node, resolve) {
  455. const parentId = node.level === 0 ? 0 : node.data.id;
  456. getDeptLazyTree(parentId).then(res => {
  457. resolve(
  458. res.data.data.map(item => {
  459. return {
  460. ...item,
  461. leaf: !item.hasChildren
  462. };
  463. })
  464. );
  465. });
  466. },
  467. addBtn: false,
  468. menu: false,
  469. size: "small",
  470. props: {
  471. label: "title",
  472. value: "value",
  473. children: "children"
  474. }
  475. },
  476. page: {
  477. pageSize: 10,
  478. currentPage: 1,
  479. total: 0
  480. },
  481. search: {},
  482. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  483. goodsOption: {},
  484. loading: false,
  485. goodData: [], // 存储所有商品信息
  486. switchDialog: false, // 报表弹窗控制
  487. userList: [],
  488. activeName: 'searchList',
  489. // 商品列表数据合计
  490. goodsListShow: [],
  491. // 商品列表暂存
  492. goodsListSave: [],
  493. pageList: {
  494. pageSize: 10,
  495. currentPage: 1,
  496. total: 0
  497. },
  498. dic: [],
  499. oldForm: {},
  500. oldDataList: [],
  501. confirmDisabled: false, // 确认禁用
  502. storageOptions: [],
  503. }
  504. },
  505. async created() {
  506. this.tableOption = await this.getColumnData(
  507. this.getColumnName(95),
  508. tableOption
  509. );
  510. this.goodsOption = await this.getColumnData(
  511. this.getColumnName(96),
  512. goodsOption
  513. );
  514. getGoods(1, 10).then(res => {
  515. if (res.data.data.total > 0) {
  516. this.goodsoptions = res.data.data.records;
  517. if (Math.ceil(res.data.data.total / 10) > 1) {
  518. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  519. getGoods(i, 10).then(e => {
  520. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  521. });
  522. }
  523. }
  524. }
  525. });
  526. gainUser().then(res => {
  527. this.userList = res.data.data;
  528. });
  529. getDeptTree().then(res => {
  530. this.dic = res.data.data
  531. })
  532. storageList().then(res => {
  533. this.storageOptions = res.data.data.records;
  534. })
  535. this.getWorkDicts('unit').then(res => {
  536. this.unitOption = res.data.data;
  537. })
  538. if (this.detailData.query) {
  539. this.disabled = true;
  540. this.option.column.map(e => {
  541. this.$set(e, 'disabled', true)
  542. })
  543. this.queryData(this.detailData.id);
  544. }
  545. },
  546. filters: {
  547. IntegerFormat(num) {
  548. return IntegerFormat(num);
  549. },
  550. decimalFormat(num) {
  551. return num ? Number(num).toFixed(2) : "0.00";
  552. }
  553. },
  554. methods: {
  555. // 查询
  556. queryData(id) {
  557. this.pageLoading = true;
  558. dataDetail(id).then(res => {
  559. res.data.data.stockDept = !res.data.data.stockDept? '': res.data.data.stockDept
  560. this.form = res.data.data;
  561. this.dataList = this.form.orderItemsList? this.form.orderItemsList: [];
  562. this.oldForm = {...this.form};
  563. this.oldDataList = [...this.dataList];
  564. delete this.form.orderItemsList;
  565. if (!this.form.stockUser) {
  566. getUserInfo().then(res => {
  567. this.$set(this.form, 'stockUser', res.data.data.id);
  568. this.$set(this.form, 'stockDept', res.data.data.deptId);
  569. })
  570. this.$set(this.form, 'stockTime', getCurrentDate()); // 默认当前日期
  571. }
  572. this.confirmDisabled = this.form.status == 4? true: false;
  573. if (this.form.status == 4) {
  574. this.option.column.map(e => {
  575. this.$set(e, 'disabled', true)
  576. })
  577. }
  578. }).finally(() => {
  579. this.pageLoading = false;
  580. })
  581. },
  582. //返回列表
  583. backToList() {
  584. this.$emit("goBack");
  585. },
  586. // 编辑按钮触发
  587. openEdit() {
  588. this.disabled = false;
  589. this.option.column.map(e => {
  590. if (this.confirmDisabled) {
  591. this.$set(e, 'disabled', true)
  592. } else {
  593. this.$set(e, 'disabled', false)
  594. }
  595. })
  596. },
  597. // 复制
  598. copyDoc() {
  599. this.$emit("copyOrder", this.form.id);
  600. },
  601. //修改提交触发
  602. editCustomer(status) {
  603. this.$refs["form"].validate((valid, done) => {
  604. done();
  605. if (valid) {
  606. this.btnLoading = true;
  607. this.form.billType = 'ORK';
  608. this.form.tradeType = 'ORK';
  609. this.$set(this.form, 'orderItemsList', this.dataList);
  610. typeSave(this.form).then(res => {
  611. this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
  612. this.queryData(res.data.data);
  613. }).finally(() => {
  614. this.btnLoading = false;
  615. })
  616. } else {
  617. return false
  618. }
  619. })
  620. },
  621. cellStyle() {
  622. return "padding:0;height:40px;";
  623. },
  624. async saveColumn() {
  625. const inSave = await this.saveColumnData(
  626. this.getColumnName(95),
  627. this.tableOption
  628. );
  629. if (inSave) {
  630. this.$message.success("保存成功");
  631. //关闭窗口
  632. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  633. this.$nextTick(() => {
  634. this.$refs.crud.doLayout()
  635. })
  636. }
  637. },
  638. async resetColumn() {
  639. this.tableOption = tableOption;
  640. const inSave = await this.delColumnData(
  641. this.getColumnName(95),
  642. tableOption
  643. );
  644. if (inSave) {
  645. this.$nextTick(() => {
  646. this.$refs.crud.doLayout()
  647. })
  648. this.$message.success("重置成功");
  649. //关闭窗口
  650. setTimeout(() => {
  651. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  652. }, 1000);
  653. }
  654. },
  655. //商品明细导入
  656. newDetails() {
  657. this.$refs["form"].validate((valid) => {
  658. if (valid) {
  659. this.dialogVisible = !this.dialogVisible;
  660. }
  661. })
  662. },
  663. rowCell(row, index) {
  664. if (row.$cellEdit == true) {
  665. this.$set(row, "$cellEdit", false);
  666. } else {
  667. this.$set(row, "$cellEdit", true);
  668. }
  669. },
  670. rowDel(row, index) {
  671. this.$confirm("确定删除数据?", {
  672. confirmButtonText: "确定",
  673. cancelButtonText: "取消",
  674. type: "warning"
  675. }).then(() => {
  676. if (row.id) {
  677. removeGoods(row.id).then(res => {
  678. this.$message({
  679. type: 'success',
  680. message: '删除成功!'
  681. })
  682. this.dataList.splice(row.$index, 1);
  683. })
  684. } else {
  685. this.$message({
  686. type: "success",
  687. message: "删除成功!"
  688. });
  689. this.dataList.splice(row.$index, 1);
  690. }
  691. });
  692. },
  693. codeChange(row) {
  694. this.goodsoptions.forEach(async e => {
  695. if (e.code == row.code) {
  696. row.itemId = e.id;
  697. row.cname = e.cname;
  698. row.code = e.code;
  699. row.corpId = e.corpId;
  700. row.corpName = e.corpName;
  701. row.unit = e.unit;
  702. row.priceCategory = e.goodsTypeName;
  703. row.price = e.price;
  704. }
  705. });
  706. },
  707. cnameChange(row) {
  708. let form = {};
  709. this.goodsoptions.forEach(async e => {
  710. if (e.id == row.itemId) {
  711. row.cname = e.cname;
  712. row.code = e.code;
  713. row.corpId = e.corpId;
  714. row.corpName = e.corpName;
  715. row.unit = e.unit;
  716. row.priceCategory = e.goodsTypeName;
  717. row.price = e.price;
  718. }
  719. });
  720. },
  721. rePick(row, index) {
  722. this.reData = {
  723. ...row,
  724. index: index
  725. };
  726. this.newDetails();
  727. },
  728. // 商品信息价格计算
  729. amountChange(row) {
  730. if (!row.orderQuantity) {
  731. row.orderQuantity = 0;
  732. }
  733. if (!row.price) {
  734. row.price = 0;
  735. }
  736. row.amount = Number(row.price) * Number(row.orderQuantity)
  737. },
  738. closeGoods() {
  739. this.selectionList = [];
  740. this.treeDeptId = "";
  741. this.reData = null;
  742. this.activeName = 'searchList';
  743. this.goodsListSave = [];
  744. },
  745. nodeClick(data) {
  746. this.treeDeptId = data.id;
  747. this.page.currentPage = 1;
  748. this.onLoad(this.page);
  749. },
  750. //商品查询
  751. onLoad(page, params = {}) {
  752. let obj = this.deepClone(Object.assign(params, this.search));
  753. this.loading = true;
  754. getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
  755. .then(res => {
  756. const data = res.data.data;
  757. this.page.total = data.total;
  758. this.goodsList = data.records;
  759. this.pageList.total = data.total;
  760. this.goodsListShow = data.records;
  761. if (this.page.total) {
  762. this.goodsOption.height = window.innerHeight - 350;
  763. }
  764. })
  765. .finally(() => {
  766. this.loading = false;
  767. });
  768. },
  769. searchChange(params, done) {
  770. this.search = this.deepClone(params);
  771. this.onLoad(this.page, params);
  772. done();
  773. },
  774. selectionChange(list) {
  775. this.selectionList = list;
  776. },
  777. rowClick(row) {
  778. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  779. },
  780. async saveGoodsColumn() {
  781. const inSave = await this.saveColumnData(
  782. this.getColumnName(96),
  783. this.goodsOption
  784. );
  785. if (inSave) {
  786. this.$message.success("保存成功");
  787. //关闭窗口
  788. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  789. this.$nextTick(() => {
  790. this.$refs.goodsCrud.doLayout()
  791. })
  792. }
  793. },
  794. async resetGoodsColumn() {
  795. this.goodsOption = goodsOption;
  796. const inSave = await this.delColumnData(
  797. this.getColumnName(96),
  798. goodsOption
  799. );
  800. if (inSave) {
  801. this.$nextTick(() => {
  802. this.$refs.goodsCrud.doLayout()
  803. })
  804. this.$message.success("重置成功");
  805. //关闭窗口
  806. setTimeout(() => {
  807. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  808. }, 1000);
  809. }
  810. },
  811. // 标签页切换
  812. tabHandle(data) {
  813. if (data.name == 'searchList') {
  814. this.goodsListShow = this.goodsList;
  815. this.page.total = this.pageList.total
  816. } else if (data.name == 'importStaging') {
  817. this.goodsListShow = this.goodsListSave;
  818. this.page.total = 0
  819. }
  820. },
  821. removeStagList(row, index) {
  822. this.goodsListSave.splice(row.$index, 1)
  823. },
  824. importStagList(row, index) {
  825. this.goodsListSave.push(row);
  826. },
  827. importGoods() {
  828. if (this.reData) {
  829. if (this.selectionList.length != 1) {
  830. return this.$message.error("重新选择的时候只能选择一条数据");
  831. } else {
  832. this.selectionList.forEach(e => {
  833. this.dataList.forEach(async (item, index) => {
  834. if (index == this.reData.index) {
  835. item.itemId = e.id;
  836. item.code = e.code;
  837. item.cname = e.cname;
  838. item.corpId = e.corpId;
  839. item.corpName = e.corpName;
  840. item.unit = e.unit;
  841. item.priceCategory = e.goodsTypeName;
  842. item.price = e.price;
  843. item.$cellEdit = true;
  844. }
  845. });
  846. });
  847. }
  848. } else {
  849. if (this.goodsListSave.length > 0) { // 暂存的有数据
  850. this.goodsListSave.forEach(async e => {
  851. this.dataList.push({
  852. itemId: e.id,
  853. code: e.code,
  854. cname: e.cname,
  855. corpId: e.corpId,
  856. corpName: e.corpName,
  857. unit: e.unit,
  858. price: e.price,
  859. amount: 0,
  860. orderQuantity: 0,
  861. storageId: this.storageOptions.length > 0? this.storageOptions[0].id: null,
  862. $cellEdit: true
  863. });
  864. });
  865. } else {
  866. this.selectionList.forEach(async e => {
  867. this.dataList.push({
  868. itemId: e.id,
  869. code: e.code,
  870. cname: e.cname,
  871. corpId: e.corpId,
  872. corpName: e.corpName,
  873. unit: e.unit,
  874. amount: 0,
  875. orderQuantity: 0,
  876. price: e.price,
  877. storageId: this.storageOptions.length > 0? this.storageOptions[0].id: null,
  878. $cellEdit: true
  879. });
  880. });
  881. }
  882. }
  883. this.dialogVisible = false;
  884. },
  885. // 验证新旧值对比
  886. verification() {
  887. if (contrastObj(this.form, this.oldForm) ||
  888. contrastList(this.dataList, this.oldDataList)) {
  889. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  890. confirmButtonText: "确定",
  891. cancelButtonText: "取消",
  892. type: "warning"
  893. }).then(() => {
  894. this.editCustomer();
  895. }).catch(() => {
  896. return false; //取消改动数据
  897. })
  898. } else {
  899. return true;
  900. }
  901. },
  902. // 确认入库
  903. confirmReceipt() {
  904. if (this.verification()) {
  905. this.$set(this.form, 'orderItemsList', this.dataList);
  906. this.btnLoading = true;
  907. confirmReceipt(this.form).then(res => {
  908. this.$message.success('入库成功!')
  909. this.queryData(this.form.id);
  910. }).finally(() => {
  911. this.btnLoading = false;
  912. })
  913. }
  914. },
  915. // 撤销入库
  916. cancelReceipt() {
  917. this.$set(this.form, 'orderItemsList', this.dataList);
  918. this.btnLoading = true;
  919. cancelReceipt(this.form).then(res => {
  920. this.$message.success('撤销成功!')
  921. this.queryData(this.form.id);
  922. }).finally(() => {
  923. this.btnLoading = false;
  924. })
  925. },
  926. },
  927. }
  928. </script>
  929. <style scoped>
  930. </style>