detailsPage.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  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">
  14. <el-button
  15. type="primary"
  16. size="small"
  17. v-if="detailData.status == 1"
  18. class="el-button--small-yh "
  19. @click.stop="openEdit"
  20. >编辑
  21. </el-button>
  22. <el-button
  23. type="primary"
  24. :disabled="disabled && detailData.status == 1"
  25. @click="editCustomer('submit')"
  26. v-if="form.id && detailData.status != 1"
  27. :loading="subLoading"
  28. size="small"
  29. >保存数据
  30. </el-button>
  31. <el-button
  32. type="primary"
  33. :disabled="disabled && detailData.status == 1"
  34. v-if="detailData.status != 1"
  35. @click="editCustomer('fix')"
  36. size="small"
  37. >提 交
  38. </el-button>
  39. </div>
  40. </div>
  41. <div class="customer-main">
  42. <containerTitle title="基础信息"></containerTitle>
  43. <basic-container>
  44. <avue-form
  45. class="trading-form"
  46. ref="form"
  47. v-model="form"
  48. :option="option"
  49. >
  50. <template slot="portOfLoad">
  51. <port-info v-model="form.portOfLoad" :disabled="true" />
  52. </template>
  53. <template slot="portOfDestination">
  54. <port-info v-model="form.portOfDestination" :disabled="true" />
  55. </template>
  56. </avue-form>
  57. </basic-container>
  58. <containerTitle title="商品信息"></containerTitle>
  59. <basic-container>
  60. <avue-crud
  61. ref="crud"
  62. :data="data"
  63. :option="tableOption"
  64. @row-del="rowDel"
  65. @saveColumn="saveColumn"
  66. @resetColumn="resetColumn"
  67. :summary-method="summaryMethod"
  68. :cell-style="cellStyle"
  69. >
  70. <template slot-scope="{ row }" slot="orderQuantity">
  71. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  72. </template>
  73. </avue-crud>
  74. </basic-container>
  75. <containerTitle title="运费明细"></containerTitle>
  76. <basic-container>
  77. <avue-crud
  78. ref="freightCrud"
  79. :data="freightData"
  80. :option="freightOption"
  81. @row-del="rowDel"
  82. @saveColumn="saveFreightColumn"
  83. :cell-style="cellStyle"
  84. >
  85. <template slot="shippingHouse" slot-scope="{ row, index }">
  86. <crop-select
  87. v-show="row.$cellEdit"
  88. v-model="row.shippingHouse"
  89. :cropIndex="index"
  90. @getCorpData="rowCorpData"
  91. corpType="GYS"
  92. ></crop-select>
  93. <span v-show="!row.$cellEdit">{{ row.shippingHouseName }}</span>
  94. </template>
  95. <template slot="priorityReferrer" slot-scope="{ row }">
  96. <el-checkbox
  97. :disabled="!row.$cellEdit"
  98. v-model="row.priorityReferrer"
  99. :true-label="1"
  100. :false-label="0"
  101. />
  102. </template>
  103. <template slot="oceanFreight" slot-scope="{ row }">
  104. <el-input
  105. size="small"
  106. v-model="row.oceanFreight"
  107. oninput="value=value.replace(/[^0-9.]/g,'').replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3')"
  108. placeholder="请输入"
  109. :disabled="detailData.status == 1"
  110. v-if="row.$cellEdit"
  111. />
  112. <span v-else>{{ row.oceanFreight }}</span>
  113. </template>
  114. <template slot="menu" slot-scope="{ row, index }">
  115. <el-button
  116. size="small"
  117. icon="el-icon-edit"
  118. type="text"
  119. @click="rowCell(row, index)"
  120. :disabled="disabled"
  121. >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
  122. >
  123. <el-button
  124. size="small"
  125. icon="el-icon-edit"
  126. type="text"
  127. @click="rowDel(row, index)"
  128. :disabled="detailData.status == 1"
  129. >删 除</el-button
  130. >
  131. </template>
  132. <template slot="menuLeft">
  133. <el-button
  134. type="primary"
  135. icon="el-icon-plus"
  136. size="small"
  137. @click.stop="addFreight"
  138. :disabled="detailData.status == 1"
  139. >新增</el-button
  140. ></template
  141. >
  142. </avue-crud>
  143. </basic-container>
  144. </div>
  145. <el-dialog
  146. title="导入商品"
  147. append-to-body
  148. class="el-dialogDeep"
  149. :visible.sync="dialogVisible"
  150. width="80%"
  151. :close-on-click-modal="false"
  152. :destroy-on-close="true"
  153. :close-on-press-escape="false"
  154. @close="closeGoods"
  155. top="5vh"
  156. v-dialog-drag
  157. >
  158. <span>
  159. <el-row>
  160. <el-col :span="4">
  161. <div>
  162. <el-scrollbar>
  163. <basic-container>
  164. <avue-tree
  165. :option="treeOption"
  166. @node-click="nodeClick"
  167. :style="treeStyle"
  168. />
  169. </basic-container>
  170. </el-scrollbar>
  171. </div>
  172. </el-col>
  173. <el-col :span="20">
  174. <avue-crud
  175. :option="goodsOption"
  176. :table-loading="loading"
  177. :data="goodsList"
  178. ref="goodsCrud"
  179. @refresh-change="refreshChange"
  180. @selection-change="selectionChange"
  181. @row-click="rowClick"
  182. :page.sync="page"
  183. @on-load="onLoad"
  184. @saveColumn="saveGoodsColumn"
  185. @resetColumn="resetGoodsColumn"
  186. :cell-style="cellStyle"
  187. ></avue-crud>
  188. </el-col>
  189. </el-row>
  190. </span>
  191. <span slot="footer" class="dialog-footer">
  192. <el-button @click="dialogVisible = false">取 消</el-button>
  193. <el-button
  194. type="primary"
  195. @click="importGoods"
  196. :disabled="selectionList.length == 0"
  197. >导入</el-button
  198. >
  199. </span>
  200. </el-dialog>
  201. <report-dialog
  202. :switchDialog="switchDialog"
  203. :reportId="form.id"
  204. reportName="客户询价"
  205. @onClose="onClose()"
  206. ></report-dialog>
  207. </div>
  208. </template>
  209. <script>
  210. import tableOption from "./config/customerContact.json";
  211. import goodsOption from "./config/commodity.json";
  212. import freightOption from "./config/freight.json";
  213. import customerDialog from "@/components/customer-dialog/main";
  214. import {
  215. detail,
  216. submit,
  217. getDeptLazyTree,
  218. getGoods,
  219. getPorts,
  220. delItem,
  221. commit
  222. } from "@/api/basicData/shippingInquiry";
  223. import reportDialog from "@/components/report-dialog/main";
  224. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  225. import { contrastObj, contrastList } from "@/util/contrastData";
  226. import _ from "lodash";
  227. export default {
  228. name: "detailsPageEdit",
  229. data() {
  230. return {
  231. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  232. switchDialog: false,
  233. form: {},
  234. disabled: false,
  235. dialogVisible: false,
  236. freightOption: freightOption,
  237. tableOption: {},
  238. option: {
  239. menuBtn: false,
  240. labelWidth: 100,
  241. disabled: true,
  242. column: [
  243. {
  244. label: "系统号",
  245. prop: "sysNo",
  246. span: 8
  247. },
  248. {
  249. label: "起运港",
  250. prop: "portOfLoad",
  251. span: 8,
  252. type: "select",
  253. filterable: true,
  254. dicData: [],
  255. props: {
  256. label: "name",
  257. value: "name"
  258. }
  259. },
  260. {
  261. label: "目的港",
  262. prop: "portOfDestination",
  263. span: 8,
  264. type: "select",
  265. filterable: true,
  266. dicData: [],
  267. props: {
  268. label: "name",
  269. value: "name"
  270. }
  271. },
  272. {
  273. label: "订单号",
  274. prop: "orderNo",
  275. span: 8
  276. },
  277. {
  278. label: "计划交期",
  279. prop: "plannedDeliveryDate",
  280. span: 8,
  281. type: "date",
  282. format: "yyyy-MM-dd",
  283. valueFormat: "yyyy-MM-dd 00:00:00",
  284. row: true
  285. },
  286. {
  287. label: "箱型",
  288. prop: "boxPile",
  289. type: "select",
  290. dicUrl: "/api/blade-system/dict-biz/dictionary?code=boxType",
  291. props: {
  292. label: "dictValue",
  293. value: "dictValue"
  294. },
  295. span: 8
  296. },
  297. {
  298. label: "箱量",
  299. prop: "boxNumber",
  300. span: 8
  301. },
  302. {
  303. label: "起订量",
  304. prop: "minOrder",
  305. span: 8
  306. },
  307. {
  308. label: "销售指示",
  309. prop: "orderRemark",
  310. type: "textarea",
  311. minRows: 2,
  312. span: 24
  313. }
  314. ]
  315. },
  316. treeOption: {
  317. nodeKey: "id",
  318. lazy: true,
  319. treeLoad: function(node, resolve) {
  320. const parentId = node.level === 0 ? 0 : node.data.id;
  321. getDeptLazyTree(parentId).then(res => {
  322. resolve(
  323. res.data.data.map(item => {
  324. return {
  325. ...item,
  326. leaf: !item.hasChildren
  327. };
  328. })
  329. );
  330. });
  331. },
  332. addBtn: false,
  333. menu: false,
  334. size: "small",
  335. props: {
  336. label: "title",
  337. value: "value",
  338. children: "children"
  339. }
  340. },
  341. page: {
  342. pageSize: 10,
  343. currentPage: 1,
  344. total: 0
  345. },
  346. loading: false,
  347. goodsOption: {},
  348. data: [],
  349. goodsList: [],
  350. selectionList: [],
  351. treeDeptId: null,
  352. orderFeesList: [],
  353. freightData: [],
  354. oldform: {},
  355. olddata: [],
  356. oldfreightData: [],
  357. subLoading: false,
  358. pageLoading: false,
  359. showBut: true
  360. };
  361. },
  362. props: {
  363. detailData: {
  364. type: Object
  365. }
  366. },
  367. components: {
  368. reportDialog,
  369. customerDialog
  370. },
  371. async created() {
  372. if (this.detailData.id) {
  373. this.getDetail(this.detailData.id);
  374. }
  375. this.tableOption = await this.getColumnData(
  376. this.getColumnName(13),
  377. tableOption
  378. );
  379. this.goodsOption = await this.getColumnData(
  380. this.getColumnName(32),
  381. goodsOption
  382. );
  383. getPorts().then(res => {
  384. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  385. this.findObject(this.option.column, "portOfDestination").dicData =
  386. res.data;
  387. });
  388. this.getWorkDicts("product_properties").then(res => {
  389. this.findObject(this.tableOption.column, "itemProp").dicData =
  390. res.data.data;
  391. });
  392. },
  393. filters: {
  394. IntegerFormat(num) {
  395. return IntegerFormat(num);
  396. }
  397. },
  398. methods: {
  399. cellStyle() {
  400. return "padding:0;height:40px;";
  401. },
  402. rowCorpData(row) {
  403. this.data[row.index].shippingHouseName = row.cname;
  404. },
  405. rowCell(row, index) {
  406. if (row.$cellEdit == true) {
  407. this.$set(row, "$cellEdit", false);
  408. } else {
  409. this.$set(row, "$cellEdit", true);
  410. }
  411. },
  412. rowDel(row, index) {
  413. this.$confirm("确定删除数据?", {
  414. confirmButtonText: "确定",
  415. cancelButtonText: "取消",
  416. type: "warning"
  417. }).then(() => {
  418. if (row.id) {
  419. delItem(row.id).then(res => {
  420. this.$message({
  421. type: "success",
  422. message: "删除成功!"
  423. });
  424. this.freightData.splice(index, 1);
  425. });
  426. } else {
  427. this.$message({
  428. type: "success",
  429. message: "删除成功!"
  430. });
  431. this.freightData.splice(index, 1);
  432. }
  433. });
  434. },
  435. rowSave(row) {
  436. this.$set(row, "$cellEdit", false);
  437. },
  438. importGoods() {
  439. this.selectionList.forEach(e => {
  440. this.data.push({
  441. itemId: e.id,
  442. code: e.code,
  443. cname: e.cname,
  444. priceCategory: e.goodsTypeName,
  445. itemUrl: e.url,
  446. itemProp: null,
  447. itemDescription: null,
  448. itemType: null,
  449. orderQuantity: 0,
  450. tradeTerms: null,
  451. price: 0,
  452. amount: 0,
  453. taxRate: 0,
  454. unit: e.unit,
  455. remarks: null,
  456. $cellEdit: true
  457. });
  458. });
  459. this.dialogVisible = false;
  460. },
  461. closeGoods() {
  462. this.selectionList = [];
  463. this.treeDeptId = "";
  464. },
  465. selectionChange(list) {
  466. this.selectionList = list;
  467. },
  468. rowClick(row) {
  469. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  470. },
  471. nodeClick(data) {
  472. this.treeDeptId = data.id;
  473. this.page.currentPage = 1;
  474. this.onLoad(this.page);
  475. },
  476. //费用查询
  477. onLoad(page, params = {}) {
  478. this.loading = true;
  479. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  480. const data = res.data.data;
  481. this.page.total = data.total;
  482. this.goodsList = data.records;
  483. this.loading = false;
  484. if (this.page.total) {
  485. this.goodsOption.height = window.innerHeight - 350;
  486. }
  487. });
  488. },
  489. getDetail(id) {
  490. this.showBut = false;
  491. this.pageLoading = true;
  492. detail(id)
  493. .then(res => {
  494. this.form = res.data.data;
  495. this.data = res.data.data.itemsVOList
  496. ? res.data.data.itemsVOList
  497. : [];
  498. this.freightData = res.data.data.orderFreightList
  499. ? res.data.data.orderFreightList
  500. : [];
  501. this.oldform = res.data.data;
  502. this.olddata = this.deepClone(
  503. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  504. );
  505. this.oldfreightData = this.deepClone(
  506. res.data.data.orderFreightList ? res.data.data.orderFreightList : []
  507. );
  508. })
  509. .finally(() => {
  510. this.showBut = true;
  511. this.pageLoading = false;
  512. });
  513. },
  514. addFreight() {
  515. this.freightData.push({ $cellEdit: true });
  516. },
  517. //修改提交触发
  518. editCustomer(status, status2) {
  519. this.$refs["form"].validate((valid, done) => {
  520. done();
  521. if (valid) {
  522. if (status == "submit") {
  523. this.subLoading = true;
  524. submit({
  525. id: this.form.id,
  526. orderFreightList: this.freightData
  527. })
  528. .then(res => {
  529. this.$message.success("修改成功");
  530. this.form = res.data.data;
  531. this.data = res.data.data.itemsVOList
  532. ? res.data.data.itemsVOList
  533. : [];
  534. this.freightData = res.data.data.orderFreightList
  535. ? res.data.data.orderFreightList
  536. : [];
  537. this.oldform = res.data.data;
  538. this.olddata = this.deepClone(
  539. res.data.data.itemsVOList ? res.data.data.itemsVOList : []
  540. );
  541. this.oldfreightData = this.deepClone(
  542. res.data.data.orderFreightList
  543. ? res.data.data.orderFreightList
  544. : []
  545. );
  546. if (status2 == "goBack") {
  547. this.$emit("goBack");
  548. }
  549. })
  550. .finally(() => {
  551. this.subLoading = false;
  552. });
  553. }
  554. if (status == "fix") {
  555. commit({
  556. id: this.form.id,
  557. orderFreightList: this.freightData
  558. }).then(res => {
  559. this.$message.success("提交成功");
  560. this.form = res.data.data;
  561. this.data = res.data.data.orderItemsList
  562. ? res.data.data.orderItemsList
  563. : [];
  564. this.freightData = res.data.data.orderFreightList
  565. ? res.data.data.orderFreightList
  566. : [];
  567. this.oldform = res.data.data;
  568. this.olddata = this.deepClone(
  569. res.data.data.orderItemsList ? res.data.data.orderItemsList : []
  570. );
  571. this.oldfreightData = this.deepClone(
  572. res.data.data.orderFreightList
  573. ? res.data.data.orderFreightList
  574. : []
  575. );
  576. });
  577. }
  578. } else {
  579. return false;
  580. }
  581. });
  582. },
  583. //返回列表
  584. backToList() {
  585. if (
  586. contrastObj(this.form, this.oldform) ||
  587. contrastList(this.data, this.olddata) ||
  588. contrastList(this.freightData, this.oldfreightData)
  589. ) {
  590. this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
  591. confirmButtonText: "确定",
  592. cancelButtonText: "取消",
  593. type: "warning"
  594. })
  595. .then(() => {
  596. this.editCustomer("submit", "goBack");
  597. })
  598. .catch(() => {
  599. this.$emit("goBack");
  600. });
  601. } else {
  602. this.$emit("goBack");
  603. }
  604. },
  605. onClose(val) {
  606. this.switchDialog = val;
  607. },
  608. summaryMethod({ columns, data }) {
  609. const sums = [];
  610. if (columns.length > 0) {
  611. columns.forEach((item, index) => {
  612. sums[0] = "合计";
  613. if (item.property == "orderQuantity" || item.property == "amount") {
  614. let qtySum = 0;
  615. let amountSum = 0;
  616. data.forEach(e => {
  617. qtySum = _.add(qtySum, Number(e.orderQuantity));
  618. amountSum = _.add(amountSum, Number(e.amount));
  619. });
  620. //数量总计
  621. if (item.property == "orderQuantity") {
  622. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  623. }
  624. //金额总计
  625. if (item.property == "amount") {
  626. sums[index] = micrometerFormat(amountSum);
  627. }
  628. }
  629. });
  630. }
  631. return sums;
  632. },
  633. openEdit() {
  634. this.detailData.status = 2;
  635. this.option = this.$options.data().option;
  636. },
  637. async saveColumn() {
  638. const inSave = await this.saveColumnData(
  639. this.getColumnName(13),
  640. this.tableOption
  641. );
  642. if (inSave) {
  643. this.$message.success("保存成功");
  644. //关闭窗口
  645. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  646. }
  647. },
  648. async resetColumn() {
  649. this.tableOption = tableOption;
  650. const inSave = await this.delColumnData(
  651. this.getColumnName(13),
  652. tableOption
  653. );
  654. if (inSave) {
  655. this.$message.success("重置成功");
  656. //关闭窗口
  657. setTimeout(() => {
  658. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  659. }, 1000);
  660. }
  661. },
  662. async saveGoodsColumn() {
  663. const inSave = await this.saveColumnData(
  664. this.getColumnName(32),
  665. this.goodsOption
  666. );
  667. if (inSave) {
  668. this.$message.success("保存成功");
  669. //关闭窗口
  670. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  671. }
  672. },
  673. async resetGoodsColumn() {
  674. this.goodsOption = goodsOption;
  675. const inSave = await this.delColumnData(
  676. this.getColumnName(32),
  677. goodsOption
  678. );
  679. if (inSave) {
  680. this.$message.success("重置成功");
  681. //关闭窗口
  682. setTimeout(() => {
  683. this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
  684. }, 1000);
  685. }
  686. }
  687. }
  688. };
  689. </script>
  690. <style lang="scss" scoped>
  691. .trading-form ::v-deep .el-form-item {
  692. margin-bottom: 8px !important;
  693. }
  694. ::v-deep .el-form-item__error {
  695. display: none !important;
  696. }
  697. ::v-deep .select-component {
  698. display: flex !important;
  699. }
  700. </style>