detail.vue 28 KB

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