detailsPage.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  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. >返回列表
  11. </el-button>
  12. </div>
  13. <div class="add-customer-btn" v-if="showBut" size="small">
  14. <el-button type="success" disabled size="small">
  15. 复制新单
  16. </el-button>
  17. <el-button
  18. type="primary"
  19. :disabled="disabled"
  20. @click="editCustomer"
  21. :loading="subLoading"
  22. v-if="detailData.status != 1"
  23. size="small"
  24. >{{ form.id ? "确认修改" : "确认新增" }}
  25. </el-button>
  26. </div>
  27. </div>
  28. <div class="customer-main">
  29. <containerTitle title="基础信息"></containerTitle>
  30. <basic-container>
  31. <avue-form
  32. ref="form"
  33. class="trading-form"
  34. v-model="form"
  35. :option="option"
  36. >
  37. <template slot="corpId">
  38. <select-component
  39. v-model="form.corpId"
  40. :configuration="configuration"
  41. :disabled="detailData.status == 1"
  42. ></select-component>
  43. </template>
  44. <template slot="exchangeRate">
  45. <el-input
  46. size="mini"
  47. v-model="form.exchangeRate"
  48. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  49. @change="rateChange"
  50. placeholder="请输入 汇率"
  51. :disabled="detailData.status == 1"
  52. ><template slot="append">%</template></el-input
  53. >
  54. </template>
  55. <template slot="orderNo">
  56. <el-input
  57. size="mini"
  58. v-model="form.orderNo"
  59. oninput="this.value=this.value.toUpperCase()"
  60. placeholder="请输入 "
  61. :disabled="detailData.status == 1"
  62. />
  63. </template>
  64. </avue-form>
  65. </basic-container>
  66. <div>
  67. <containerTitle title="商品信息"></containerTitle>
  68. <basic-container>
  69. <avue-crud
  70. ref="crud"
  71. :data="data"
  72. :option="tableOption"
  73. @row-del="rowDel"
  74. @selection-change="goodsSelectionChange"
  75. @saveColumn="saveColumn"
  76. :summary-method="summaryMethod"
  77. :cell-style="cellStyle"
  78. >
  79. <template slot="price" slot-scope="{ row }">
  80. <el-input
  81. v-if="row.$cellEdit"
  82. v-model="row.price"
  83. size="small"
  84. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  85. @change="priceChange(row)"
  86. ></el-input>
  87. <span v-else>{{ row.price }}</span>
  88. </template>
  89. <template slot="orderQuantity" slot-scope="{ row }">
  90. <el-input
  91. v-if="row.$cellEdit"
  92. v-model="row.orderQuantity"
  93. size="small"
  94. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  95. @change="quantityChange(row)"
  96. ></el-input>
  97. <span v-else>{{ row.orderQuantity }}</span>
  98. </template>
  99. <template slot="cname" slot-scope="{ row, index }">
  100. <el-button
  101. size="small"
  102. type="text"
  103. @click="rePick(row, index)"
  104. :disabled="disabled"
  105. class="picker"
  106. style="padding:4px 10px;float:left"
  107. >选择</el-button
  108. >
  109. <span> {{ row.cname }}</span>
  110. </template>
  111. <template slot="itemType" slot-scope="{ row }">
  112. <el-select
  113. v-if="row.$cellEdit"
  114. v-model="row.itemType"
  115. filterable
  116. allow-create
  117. default-first-option
  118. placeholder="请输入"
  119. @focus="itemTypeFocus(row)"
  120. size="small"
  121. >
  122. <el-option
  123. v-for="(item, index) in itemtypeList"
  124. :key="index"
  125. :label="item.value"
  126. :value="item.value"
  127. >
  128. </el-option>
  129. </el-select>
  130. <span v-else>{{ row.itemType }}</span>
  131. </template>
  132. <template slot="menuLeft">
  133. <el-button
  134. type="primary"
  135. icon="el-icon-plus"
  136. size="small"
  137. @click.stop="newDetails"
  138. :disabled="detailData.status == 1"
  139. >新增明细</el-button
  140. >
  141. <el-button
  142. type="info"
  143. icon="el-icon-printer"
  144. size="small"
  145. @click.stop="openReport()"
  146. >报 表</el-button
  147. >
  148. <el-button
  149. type="warning"
  150. icon="el-icon-plus"
  151. size="small"
  152. :disabled="detailData.status == 1 || orderItemIds.length == 0"
  153. @click="getInvoice"
  154. >生成收货单
  155. </el-button>
  156. </template>
  157. <template slot="menu" slot-scope="{ row, index }">
  158. <el-button
  159. size="small"
  160. icon="el-icon-edit"
  161. type="text"
  162. @click="rowCell(row, index)"
  163. :disabled="disabled"
  164. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  165. >
  166. <el-button
  167. size="small"
  168. icon="el-icon-edit"
  169. type="text"
  170. @click="rowDel(row, index)"
  171. :disabled="detailData.status == 1"
  172. >删 除</el-button
  173. >
  174. </template>
  175. </avue-crud>
  176. </basic-container>
  177. </div>
  178. <fee-info
  179. ref="feeInfo"
  180. :orderFeesList="orderFeesList"
  181. :disabled="detailData.status == 1"
  182. feeUrl="/trade-purchase/purchase-order/removeByFees"
  183. />
  184. <upload-file
  185. ref="uploadFile"
  186. title="合同附件"
  187. :orderFilesList="orderFilesList"
  188. :disabled="detailData.status == 1"
  189. delUrl="/trade-purchase/purchase-order/removeByFiles"
  190. />
  191. <div>
  192. <containerTitle title="银行信息"></containerTitle>
  193. <basic-container>
  194. <avue-form
  195. class="trading-form"
  196. ref="form"
  197. v-model="form"
  198. :option="bankOption"
  199. />
  200. </basic-container>
  201. </div>
  202. </div>
  203. <el-dialog
  204. title="导入商品"
  205. append-to-body
  206. class="el-dialogDeep"
  207. :visible.sync="dialogVisible"
  208. width="60%"
  209. :close-on-click-modal="false"
  210. :destroy-on-close="true"
  211. :close-on-press-escape="false"
  212. @close="closeGoods"
  213. top="10vh"
  214. >
  215. <span>
  216. <el-row>
  217. <el-col :span="5">
  218. <div>
  219. <el-scrollbar>
  220. <basic-container style="margin-top:45px">
  221. <avue-tree :option="treeOption" @node-click="nodeClick" />
  222. </basic-container>
  223. </el-scrollbar>
  224. </div>
  225. </el-col>
  226. <el-col :span="19">
  227. <avue-crud
  228. :option="goodsOption"
  229. :table-loading="loading"
  230. :data="goodsList"
  231. ref="goodsCrud"
  232. @refresh-change="refreshChange"
  233. @selection-change="selectionChange"
  234. @row-click="rowClick"
  235. :page.sync="page"
  236. @on-load="onLoad"
  237. @saveColumn="saveGoodsColumn"
  238. :cell-style="cellStyle"
  239. ></avue-crud>
  240. </el-col>
  241. </el-row>
  242. </span>
  243. <span slot="footer" class="dialog-footer">
  244. <el-button @click="dialogVisible = false">取 消</el-button>
  245. <el-button
  246. type="primary"
  247. @click="importGoods"
  248. :disabled="selectionList.length == 0"
  249. >导入</el-button
  250. >
  251. </span>
  252. </el-dialog>
  253. <report-dialog
  254. :switchDialog="switchDialog"
  255. :reportId="form.id"
  256. reportName="客户询价"
  257. @onClose="onClose()"
  258. ></report-dialog>
  259. </div>
  260. </template>
  261. <script>
  262. import tableOption from "./config/customerContact.json";
  263. import goodsOption from "./config/commodity.json";
  264. import feeInfo from "@/components/fee-info/main";
  265. import uploadFile from "@/components/upload-file/main";
  266. import {
  267. detail,
  268. submit,
  269. delItem,
  270. getDeptLazyTree,
  271. getGoods,
  272. getSysNo,
  273. getSpecification
  274. } from "@/api/exportTrade/purchaseContract";
  275. import _ from "lodash";
  276. import reportDialog from "@/components/report-dialog/main";
  277. import { contrastObj, contrastList } from "@/util/contrastData";
  278. import {
  279. isvalidatemobile,
  280. validatename,
  281. micrometerFormat
  282. } from "@/util/validate";
  283. export default {
  284. name: "detailsPageEdit",
  285. data() {
  286. const validatePhone = (rule, value, callback) => {
  287. if (value != "") {
  288. if (isvalidatemobile(value)[0]) {
  289. this.$message.error("手机号码格式不正确");
  290. callback(new Error(isvalidatemobile(value)[1]));
  291. } else {
  292. callback();
  293. }
  294. } else {
  295. callback();
  296. }
  297. };
  298. const validateName = (rule, value, callback) => {
  299. if (value != "") {
  300. if (validatename(value)) {
  301. this.$message.error("联系人格式不正确");
  302. callback(new Error(validatename(value)));
  303. } else {
  304. callback();
  305. }
  306. } else {
  307. callback();
  308. }
  309. };
  310. return {
  311. configuration: {
  312. multipleChoices: false,
  313. multiple: false,
  314. collapseTags: false,
  315. placeholder: "请点击右边按钮选择",
  316. dicData: []
  317. },
  318. switchDialog: false,
  319. form: {
  320. orderStatus: "录入"
  321. },
  322. disabled: false,
  323. dialogVisible: false,
  324. tableOption: tableOption,
  325. option: {
  326. menuBtn: false,
  327. labelWidth: 100,
  328. disabled: false,
  329. column: [
  330. {
  331. label: "客户名称",
  332. prop: "corpId",
  333. rules: [
  334. {
  335. required: true,
  336. message: "",
  337. trigger: "blur"
  338. }
  339. ],
  340. span: 16,
  341. slot: true
  342. },
  343. {
  344. label: "系统号",
  345. prop: "sysNo",
  346. span: 8,
  347. disabled: true
  348. },
  349. {
  350. label: "联系人",
  351. prop: "corpAttn",
  352. span: 8
  353. },
  354. {
  355. label: "电话",
  356. prop: "corpTel",
  357. span: 8
  358. },
  359. {
  360. label: "订单状态",
  361. prop: "orderStatus",
  362. span: 8,
  363. type: "select",
  364. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  365. props: {
  366. label: "dictValue",
  367. value: "dictValue"
  368. }
  369. },
  370. {
  371. label: "采购日期",
  372. prop: "businesDate",
  373. span: 8,
  374. type: "date",
  375. format: "yyyy-MM-dd",
  376. valueFormat: "yyyy-MM-dd 00:00:00",
  377. rules: [
  378. {
  379. required: true,
  380. message: "",
  381. trigger: "blur"
  382. }
  383. ]
  384. },
  385. {
  386. label: "预交日期",
  387. prop: "plannedDeliveryDate",
  388. span: 8,
  389. type: "date",
  390. format: "yyyy-MM-dd",
  391. valueFormat: "yyyy-MM-dd 00:00:00"
  392. },
  393. {
  394. label: "实交日期",
  395. prop: "requiredDeliveryDate",
  396. span: 8,
  397. type: "date",
  398. format: "yyyy-MM-dd",
  399. valueFormat: "yyyy-MM-dd 00:00:00"
  400. },
  401. {
  402. label: "是否开票",
  403. prop: "ifInvoice",
  404. span: 8,
  405. type: "select",
  406. dicUrl: "/api/blade-system/dict-biz/dictionary?code=ifInvoice",
  407. props: {
  408. label: "dictValue",
  409. value: "dictValue"
  410. }
  411. },
  412. {
  413. label: "付款方式",
  414. prop: "paymentType",
  415. span: 8,
  416. type: "select",
  417. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  418. props: {
  419. label: "dictValue",
  420. value: "dictValue"
  421. }
  422. },
  423. {
  424. label: "付款说明",
  425. prop: "paymentTypeDescription",
  426. span: 8
  427. },
  428. {
  429. label: "采购订单号",
  430. prop: "orderNo",
  431. span: 8
  432. },
  433. {
  434. label: "币别",
  435. prop: "currency",
  436. span: 8,
  437. type: "select",
  438. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  439. props: {
  440. label: "dictValue",
  441. value: "dictValue"
  442. },
  443. change: ({ value }) => {
  444. if (value == "CNY") {
  445. this.form.exchangeRate = 1;
  446. }
  447. if (value == "USD") {
  448. this.form.exchangeRate = 6.3843;
  449. }
  450. }
  451. },
  452. {
  453. label: "汇率",
  454. prop: "exchangeRate",
  455. span: 8,
  456. slot: true,
  457. row: true,
  458. disabled: true
  459. },
  460. {
  461. label: "备注",
  462. prop: "orderRemark",
  463. type: "textarea",
  464. minRows: 2,
  465. span: 24
  466. }
  467. ]
  468. },
  469. treeOption: {
  470. nodeKey: "id",
  471. lazy: true,
  472. treeLoad: function(node, resolve) {
  473. const parentId = node.level === 0 ? 0 : node.data.id;
  474. getDeptLazyTree(parentId).then(res => {
  475. resolve(
  476. res.data.data.map(item => {
  477. return {
  478. ...item,
  479. leaf: !item.hasChildren
  480. };
  481. })
  482. );
  483. });
  484. },
  485. addBtn: false,
  486. menu: false,
  487. size: "small",
  488. props: {
  489. label: "title",
  490. value: "value",
  491. children: "children"
  492. }
  493. },
  494. bankOption: {
  495. menuBtn: false,
  496. labelWidth: 100,
  497. column: [
  498. {
  499. label: "银行",
  500. prop: "banks",
  501. span: 8
  502. },
  503. {
  504. label: "银行信息",
  505. prop: "banksAccountName",
  506. span: 16,
  507. type: "textarea",
  508. minRows: 2
  509. }
  510. ]
  511. },
  512. insuranceOption: {
  513. menuBtn: false,
  514. labelWidth: 100,
  515. column: [
  516. {
  517. label: "保险描述",
  518. prop: "insuranceRemarks",
  519. span: 24,
  520. type: "textarea",
  521. minRows: 2
  522. }
  523. ]
  524. },
  525. markOption: {
  526. menuBtn: false,
  527. labelWidth: 100,
  528. column: [
  529. {
  530. label: "唛头描述",
  531. prop: "marks",
  532. span: 24,
  533. type: "textarea",
  534. minRows: 2
  535. }
  536. ]
  537. },
  538. page: {
  539. pageSize: 10,
  540. currentPage: 1,
  541. total: 0
  542. },
  543. loading: false,
  544. goodsOption: {},
  545. data: [],
  546. goodsList: [],
  547. selectionList: [],
  548. treeDeptId: null,
  549. orderFeesList: [],
  550. orderFilesList: [],
  551. orderItemIds: [],
  552. itemtypeList: [],
  553. goodsSelections: [],
  554. reData: null,
  555. oldform: {
  556. orderStatus: "录入"
  557. },
  558. olddata: [],
  559. oldorderFeesList: [],
  560. oldorderFilesList: [],
  561. subLoading: false,
  562. pageLoading: false,
  563. showBut: true
  564. };
  565. },
  566. props: {
  567. detailData: {
  568. type: Object
  569. }
  570. },
  571. components: {
  572. reportDialog,
  573. feeInfo,
  574. uploadFile
  575. },
  576. async created() {
  577. if (this.detailData.id) {
  578. this.getDetail(this.detailData.id);
  579. }
  580. this.tableOption = await this.getColumnData(
  581. this.getColumnName(3),
  582. tableOption
  583. );
  584. this.goodsOption = await this.getColumnData(
  585. this.getColumnName(27),
  586. goodsOption
  587. );
  588. if (this.detailData.status == 1) {
  589. this.option.disabled = true;
  590. this.bankOption.disabled = true;
  591. this.insuranceOption.disabled = true;
  592. this.markOption.disabled = true;
  593. }
  594. let _this = this;
  595. this.tableOption.column.forEach(e => {
  596. if (e.prop == "taxRate") {
  597. e.formatter = function(row) {
  598. return _this.textFormat(
  599. Number(row.taxRate ? row.taxRate : 0) / 100,
  600. "0.00%"
  601. );
  602. };
  603. }
  604. if (e.prop == "amount" || e.prop == "price") {
  605. e.formatter = function(row) {
  606. return _this.textFormat(
  607. Number(row.amount ? row.amount : 0),
  608. "#,##0.00"
  609. );
  610. };
  611. }
  612. });
  613. this.getWorkDicts("product_properties").then(res => {
  614. this.findObject(this.tableOption.column, "itemProp").dicData =
  615. res.data.data;
  616. });
  617. this.getWorkDicts("unit").then(res => {
  618. this.findObject(this.tableOption.column, "unit").dicData = res.data.data;
  619. });
  620. },
  621. methods: {
  622. cellStyle() {
  623. return "padding:0;height:40px;";
  624. },
  625. rePick(row, index) {
  626. this.reData = {
  627. ...row,
  628. index: index
  629. };
  630. this.newDetails();
  631. },
  632. rowCell(row, index) {
  633. if (row.$cellEdit == true) {
  634. this.$set(row, "$cellEdit", false);
  635. } else {
  636. this.$set(row, "$cellEdit", true);
  637. }
  638. },
  639. itemTypeFocus(row) {
  640. this.itemtypeList = [];
  641. getSpecification({ goodId: row.itemId }).then(res => {
  642. const data = res.data.data;
  643. this.itemtypeList = data.map(item => ({ value: item }));
  644. });
  645. },
  646. priceChange(row) {
  647. console.log(row);
  648. if (!row.price) {
  649. row.price = 0;
  650. } else {
  651. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  652. }
  653. },
  654. quantityChange(row) {
  655. if (Number(row.orderQuantity) < Number(row.actualQuantity)) {
  656. row.orderQuantity = row.actualQuantity;
  657. this.$message.error("修改的数量不能低于已收数量");
  658. }
  659. if (!row.orderQuantity) {
  660. row.orderQuantity = 0;
  661. } else {
  662. row.amount = _.multiply(row.price, row.orderQuantity).toFixed(2);
  663. }
  664. },
  665. rowSave(row) {
  666. console.log(row);
  667. this.$set(row, "$cellEdit", false);
  668. },
  669. rowDel(row, index) {
  670. this.$confirm("确定删除数据?", {
  671. confirmButtonText: "确定",
  672. cancelButtonText: "取消",
  673. type: "warning"
  674. }).then(() => {
  675. if (row.id) {
  676. delItem(row.id).then(res => {
  677. this.$message({
  678. type: "success",
  679. message: "删除成功!"
  680. });
  681. this.data.splice(index, 1);
  682. });
  683. } else {
  684. this.$message({
  685. type: "success",
  686. message: "删除成功!"
  687. });
  688. this.data.splice(index, 1);
  689. }
  690. });
  691. },
  692. importGoods() {
  693. if (this.reData) {
  694. console.log(this.reData);
  695. if (this.selectionList.length != 1) {
  696. return this.$message.error("重新选择的时候只能选择一条数据");
  697. } else {
  698. this.selectionList.forEach(e => {
  699. this.data.forEach((item, index) => {
  700. if (index == this.reData.index) {
  701. item.itemId = e.id;
  702. item.code = e.code;
  703. item.cname = e.cname;
  704. item.priceCategory = e.goodsTypeName;
  705. item.itemUrl = e.url;
  706. item.itemProp = this.reData.itemProp;
  707. item.itemDescription = e.cnameDescription;
  708. item.itemType = this.reData.itemType;
  709. item.tradeTerms = this.reData.tradeTerms;
  710. item.price = this.reData.price;
  711. item.orderQuantity = this.reData.orderQuantity;
  712. item.insurance = this.reData.insurance;
  713. item.freight = this.reData.freight;
  714. item.discount = this.reData.discount;
  715. item.amount = this.reData.amount;
  716. item.taxRate = this.reData.taxRate;
  717. item.unit = e.unit;
  718. item.remarks = this.reData.remarks;
  719. item.$cellEdit = true;
  720. }
  721. });
  722. });
  723. }
  724. } else {
  725. this.selectionList.forEach(e => {
  726. this.data.push({
  727. itemId: e.id,
  728. code: e.code,
  729. cname: e.cname,
  730. priceCategory: e.goodsTypeName,
  731. itemUrl: e.url,
  732. itemProp: null,
  733. itemDescription: e.cnameDescription,
  734. itemType: null,
  735. tradeTerms: null,
  736. price: 0,
  737. orderQuantity: 0,
  738. insurance: 0,
  739. freight: 0,
  740. discount: null,
  741. amount: 0,
  742. taxRate: 0,
  743. unit: e.unit,
  744. remarks: null,
  745. $cellEdit: true
  746. });
  747. });
  748. }
  749. this.dialogVisible = false;
  750. },
  751. closeGoods() {
  752. this.selectionList = [];
  753. this.treeDeptId = "";
  754. this.reData = null;
  755. },
  756. goodsSelectionChange(list) {
  757. this.goodsSelections = list;
  758. this.orderItemIds = [];
  759. list.map(e => {
  760. this.orderItemIds.push(e.id);
  761. });
  762. },
  763. selectionChange(list) {
  764. this.selectionList = list;
  765. },
  766. rowClick(row) {
  767. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  768. },
  769. nodeClick(data) {
  770. this.treeDeptId = data.id;
  771. this.page.currentPage = 1;
  772. this.onLoad(this.page);
  773. },
  774. //费用查询
  775. onLoad(page, params = {}) {
  776. this.loading = true;
  777. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  778. const data = res.data.data;
  779. this.page.total = data.total;
  780. this.goodsList = data.records;
  781. this.loading = false;
  782. if (this.page.total) {
  783. this.goodsOption.height = window.innerHeight - 550;
  784. } else {
  785. this.goodsOption.height = window.innerHeight - 475;
  786. }
  787. });
  788. },
  789. //商品明细导入
  790. newDetails() {
  791. this.dialogVisible = !this.dialogVisible;
  792. },
  793. getDetail(id) {
  794. this.showBut = false;
  795. this.pageLoading = true;
  796. detail(id)
  797. .then(res => {
  798. this.form = res.data.data;
  799. this.data = res.data.data.itemsVOList
  800. ? res.data.data.itemsVOList
  801. : [];
  802. this.orderFeesList = res.data.data.orderFeesList
  803. ? res.data.data.orderFeesList
  804. : [];
  805. this.orderFilesList = res.data.data.orderFilesList
  806. ? res.data.data.orderFilesList
  807. : [];
  808. this.configuration.dicData = this.form.corpsName;
  809. this.oldform = res.data.data;
  810. this.olddata = this.deepClone(
  811. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  812. );
  813. this.oldorderFeesList = this.deepClone(
  814. res.data.data.orderFeesList ? res.data.data.orderFeesList : []
  815. );
  816. this.oldorderFilesList = this.deepClone(
  817. res.data.data.orderFilesList ? res.data.data.orderFilesList : []
  818. );
  819. })
  820. .finally(() => {
  821. this.showBut = true;
  822. this.pageLoading = false;
  823. });
  824. },
  825. //修改提交触发
  826. editCustomer(status) {
  827. this.$refs["form"].validate((valid, done) => {
  828. done();
  829. if (valid) {
  830. const orderFeesList = this.$refs.feeInfo.submitData();
  831. for (let i = 0; i < orderFeesList.length; i++) {
  832. if (orderFeesList[i].corpId == null) {
  833. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  834. }
  835. if (orderFeesList[i].price == 0) {
  836. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  837. }
  838. if (orderFeesList[i].quantity == 0) {
  839. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  840. }
  841. }
  842. const orderFilesList = this.$refs.uploadFile.submitData();
  843. this.subLoading = true;
  844. submit({
  845. ...this.form,
  846. itemsVOList: this.data,
  847. orderFeesList: orderFeesList,
  848. orderFilesList: orderFilesList,
  849. tradeType: "CK",
  850. billType: "CG"
  851. })
  852. .then(res => {
  853. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  854. this.getDetail(res.data.data);
  855. if (status == "goBack") {
  856. this.$emit("goBack");
  857. }
  858. })
  859. .finally(() => {
  860. this.subLoading = false;
  861. });
  862. } else {
  863. return false;
  864. }
  865. });
  866. },
  867. //返回列表
  868. backToList() {
  869. let orderFeesList = this.$refs.feeInfo.submitData();
  870. let orderFilesList = this.$refs.uploadFile.submitData();
  871. if (
  872. contrastObj(this.form, this.oldform) ||
  873. contrastList(this.data, this.olddata) ||
  874. contrastList(orderFeesList, this.oldorderFeesList) ||
  875. contrastList(orderFilesList, this.oldorderFilesList)
  876. ) {
  877. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  878. confirmButtonText: "确定",
  879. cancelButtonText: "取消",
  880. type: "warning"
  881. })
  882. .then(() => {
  883. this.editCustomer("goBack");
  884. })
  885. .catch(() => {
  886. this.$emit("goBack");
  887. });
  888. } else {
  889. this.$emit("goBack");
  890. }
  891. },
  892. openReport() {
  893. this.switchDialog = !this.switchDialog;
  894. },
  895. onClose(val) {
  896. this.switchDialog = val;
  897. },
  898. summaryMethod({ columns, data }) {
  899. const sums = [];
  900. if (columns.length > 0) {
  901. columns.forEach((item, index) => {
  902. sums[0] = "合计";
  903. if (item.property == "orderQuantity" || item.property == "amount") {
  904. let qtySum = 0;
  905. let amountSum = 0;
  906. data.forEach(e => {
  907. qtySum = _.add(qtySum, Number(e.orderQuantity));
  908. amountSum = _.add(amountSum, Number(e.amount));
  909. });
  910. //数量总计
  911. if (item.property == "orderQuantity") {
  912. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  913. }
  914. //金额总计
  915. if (item.property == "amount") {
  916. sums[index] = micrometerFormat(amountSum);
  917. }
  918. }
  919. });
  920. }
  921. return sums;
  922. },
  923. getInvoice() {
  924. if (!this.form.id) {
  925. return this.$message.error("数据未提交,请提交数据");
  926. }
  927. for (let i = 0; i < this.goodsSelections.length; i++) {
  928. if (!this.goodsSelections[i].id) {
  929. return this.$message.error("明细表未提交数据,请提交数据");
  930. }
  931. }
  932. if (this.$store.getters.outtaskStatus) {
  933. this.$alert("出口发货单存在,请保存发货单再进行操作", "温馨提示", {
  934. confirmButtonText: "确定",
  935. type: "warning",
  936. callback: action => {
  937. console.log(action);
  938. }
  939. });
  940. } else {
  941. this.inInvoice();
  942. }
  943. },
  944. inInvoice() {
  945. const data = this.deepClone(this.form);
  946. data.orderItemsList = this.deepClone(this.goodsSelections);
  947. data.orderItemsList.forEach(e => {
  948. e.actualQuantity = e.orderQuantity;
  949. e.contractAmount = e.amount;
  950. e.srcId = e.id;
  951. e.packageRemarks = e.itemProp;
  952. e.productDesc = e.itemDescription;
  953. e.specificationAndModele = e.itemType;
  954. delete e.id;
  955. delete e.version;
  956. delete e.status;
  957. delete e.createUser;
  958. delete e.createTime;
  959. delete e.updateUser;
  960. delete e.updateTime;
  961. delete e.isDeleted;
  962. });
  963. delete data.id;
  964. delete data.version;
  965. delete data.status;
  966. delete data.createUser;
  967. delete data.createTime;
  968. delete data.updateUser;
  969. delete data.updateTime;
  970. delete data.isDeleted;
  971. delete data.orderStatus;
  972. data.deliveryStatus = "录入";
  973. data.srcOrderNo = data.sysNo;
  974. delete data.sysNo;
  975. data.corpName = data.corpsName;
  976. delete data.corpsName;
  977. this.$refs.crud.toggleSelection();
  978. this.$router.$avueRouter.closeTag("/exportTrade/receipt/index");
  979. this.$router.push({
  980. path: "/exportTrade/receipt/index",
  981. query: {
  982. pageType: "Generate",
  983. data: JSON.stringify(data)
  984. }
  985. });
  986. },
  987. async saveColumn() {
  988. const inSave = await this.saveColumnData(
  989. this.getColumnName(3),
  990. this.tableOption
  991. );
  992. if (inSave) {
  993. this.$message.success("保存成功");
  994. //关闭窗口
  995. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  996. }
  997. },
  998. async saveGoodsColumn() {
  999. const inSave = await this.saveColumnData(
  1000. this.getColumnName(27),
  1001. this.goodsOption
  1002. );
  1003. if (inSave) {
  1004. this.$message.success("保存成功");
  1005. //关闭窗口
  1006. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  1007. }
  1008. }
  1009. }
  1010. };
  1011. </script>
  1012. <style lang="scss" scoped>
  1013. .trading-form ::v-deep .el-form-item {
  1014. margin-bottom: 8px !important;
  1015. }
  1016. ::v-deep .el-form-item__error {
  1017. display: none !important;
  1018. }
  1019. ::v-deep .select-component {
  1020. display: flex !important;
  1021. }
  1022. </style>