detail.vue 29 KB

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