detailsPage.vue 28 KB

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