detailsPage.vue 31 KB

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