detailsPage.vue 19 KB

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