detail.vue 28 KB

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