detailsPage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <template>
  2. <div class="borderless">
  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. <el-button
  15. class="el-button--small-yh add-customer-btn"
  16. type="primary"
  17. :disabled="disabled"
  18. @click="editCustomer"
  19. >提 交
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 60px;margin-bottom:35px">
  23. <containerTitle title="基础信息"></containerTitle>
  24. <basic-container style="margin-bottom: 10px">
  25. <avue-form ref="form" v-model="form" :option="option">
  26. <template slot="corpId">
  27. <select-component
  28. v-model="form.corpId"
  29. :configuration="configuration"
  30. :disabled="true"
  31. ></select-component>
  32. </template>
  33. <template slot="exchangeRate">
  34. <el-input
  35. size="mini"
  36. v-model="form.exchangeRate"
  37. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  38. @change="rateChange"
  39. placeholder="请输入 汇率"
  40. disabled
  41. ><template slot="append">%</template></el-input
  42. >
  43. </template>
  44. </avue-form>
  45. </basic-container>
  46. <containerTitle title="商品信息"></containerTitle>
  47. <basic-container>
  48. <avue-crud
  49. ref="crud"
  50. :data="data"
  51. :option="tableOption"
  52. @row-del="rowDel"
  53. @saveColumn="saveColumn"
  54. >
  55. <!-- <template slot="menuLeft">
  56. <el-button
  57. type="info"
  58. icon="el-icon-printer"
  59. size="small"
  60. @click.stop="openReport()"
  61. >报 表</el-button
  62. >
  63. </template> -->
  64. </avue-crud>
  65. </basic-container>
  66. <fee-info
  67. ref="feeInfo"
  68. :orderFeesList="orderFeesList"
  69. feeUrl="/trade-purchase/shipping-enquiry/removeByFees"
  70. />
  71. </div>
  72. <el-dialog
  73. title="导入商品"
  74. append-to-body
  75. class="el-dialogDeep"
  76. :visible.sync="dialogVisible"
  77. width="60%"
  78. :close-on-click-modal="false"
  79. :destroy-on-close="true"
  80. :close-on-press-escape="false"
  81. @close="closeGoods"
  82. top="10vh"
  83. >
  84. <span>
  85. <el-row>
  86. <el-col :span="5">
  87. <div>
  88. <el-scrollbar>
  89. <basic-container style="margin-top:45px">
  90. <avue-tree :option="treeOption" @node-click="nodeClick" />
  91. </basic-container>
  92. </el-scrollbar>
  93. </div>
  94. </el-col>
  95. <el-col :span="19">
  96. <avue-crud
  97. :option="goodsOption"
  98. :table-loading="loading"
  99. :data="goodsList"
  100. ref="goodsCrud"
  101. @refresh-change="refreshChange"
  102. @selection-change="selectionChange"
  103. @row-click="rowClick"
  104. :page.sync="page"
  105. @on-load="onLoad"
  106. ></avue-crud>
  107. </el-col>
  108. </el-row>
  109. </span>
  110. <span slot="footer" class="dialog-footer">
  111. <el-button @click="dialogVisible = false">取 消</el-button>
  112. <el-button
  113. type="primary"
  114. @click="importGoods"
  115. :disabled="selectionList.length == 0"
  116. >导入</el-button
  117. >
  118. </span>
  119. </el-dialog>
  120. <report-dialog
  121. :switchDialog="switchDialog"
  122. :reportId="form.id"
  123. reportName="客户询价"
  124. @onClose="onClose()"
  125. ></report-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import tableOption from "./config/customerContact.json";
  130. import goodsOption from "./config/commodity.json";
  131. import feeInfo from "@/components/fee-info/main";
  132. import {
  133. detail,
  134. submit,
  135. getDeptLazyTree,
  136. getGoods,
  137. getPorts
  138. } from "@/api/basicData/shippingInquiry";
  139. import reportDialog from "@/components/report-dialog/main";
  140. import { isvalidatemobile, validatename } from "@/util/validate";
  141. export default {
  142. name: "detailsPageEdit",
  143. data() {
  144. const validatePhone = (rule, value, callback) => {
  145. if (value != "") {
  146. if (isvalidatemobile(value)[0]) {
  147. this.$message.error("手机号码格式不正确");
  148. callback(new Error(isvalidatemobile(value)[1]));
  149. } else {
  150. callback();
  151. }
  152. } else {
  153. callback();
  154. }
  155. };
  156. const validateName = (rule, value, callback) => {
  157. if (value != "") {
  158. if (validatename(value)) {
  159. this.$message.error("联系人格式不正确");
  160. callback(new Error(validatename(value)));
  161. } else {
  162. callback();
  163. }
  164. } else {
  165. callback();
  166. }
  167. };
  168. return {
  169. configuration: {
  170. multipleChoices: false,
  171. multiple: false,
  172. collapseTags: false,
  173. placeholder: "请点击右边按钮选择",
  174. dicData: []
  175. },
  176. switchDialog: false,
  177. form: {},
  178. disabled: false,
  179. dialogVisible: false,
  180. tableOption: tableOption,
  181. option: {
  182. menuBtn: false,
  183. labelWidth: 100,
  184. disabled: true,
  185. column: [
  186. {
  187. label: "客户名称",
  188. prop: "corpId",
  189. rules: [
  190. {
  191. required: true,
  192. message: "",
  193. trigger: "blur"
  194. }
  195. ],
  196. span: 8,
  197. slot: true
  198. },
  199. {
  200. label: "系统号",
  201. prop: "sysNo",
  202. span: 8
  203. },
  204. {
  205. label: "订单状态",
  206. prop: "orderStatus",
  207. span: 8,
  208. type: "select",
  209. dicUrl: "/api/blade-system/dict-biz/dictionary?code=order_status",
  210. props: {
  211. label: "dictValue",
  212. value: "dictValue"
  213. }
  214. },
  215. {
  216. label: "联系人",
  217. prop: "corpAttn",
  218. span: 8,
  219. rules: [{ validator: validateName, trigger: "blur" }]
  220. },
  221. {
  222. label: "电话",
  223. prop: "corpTel",
  224. span: 8,
  225. rules: [{ validator: validatePhone, trigger: "blur" }]
  226. },
  227. {
  228. label: "起运港",
  229. prop: "portOfLoad",
  230. span: 8,
  231. type: "select",
  232. filterable: true,
  233. dicData: [],
  234. props: {
  235. label: "name",
  236. value: "name"
  237. }
  238. },
  239. {
  240. label: "目的港",
  241. prop: "portOfDestination",
  242. span: 8,
  243. type: "select",
  244. filterable: true,
  245. dicData: [],
  246. props: {
  247. label: "name",
  248. value: "name"
  249. }
  250. },
  251. {
  252. label: "运输方式",
  253. prop: "transport",
  254. span: 8,
  255. type: "select",
  256. dicUrl: "/api/blade-system/dict-biz/dictionary?code=mode_transport",
  257. props: {
  258. label: "dictValue",
  259. value: "dictValue"
  260. }
  261. },
  262. {
  263. label: "价格条款",
  264. prop: "priceTerms",
  265. span: 8,
  266. type: "select",
  267. dicUrl: "/api/blade-system/dict-biz/dictionary?code=pricing_terms",
  268. props: {
  269. label: "dictValue",
  270. value: "dictValue"
  271. }
  272. },
  273. {
  274. label: "条款说明",
  275. prop: "priceTermsDescription",
  276. span: 8
  277. },
  278. {
  279. label: "订单日期",
  280. prop: "businesDate",
  281. span: 8,
  282. type: "date",
  283. format: "yyyy-MM-dd",
  284. valueFormat: "yyyy-MM-dd 00:00:00"
  285. },
  286. {
  287. label: "有效日期",
  288. prop: "dateValidity",
  289. span: 8,
  290. type: "date",
  291. format: "yyyy-MM-dd",
  292. valueFormat: "yyyy-MM-dd 00:00:00"
  293. },
  294. {
  295. label: "收款方式",
  296. prop: "paymentType",
  297. span: 8,
  298. type: "select",
  299. dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
  300. props: {
  301. label: "dictValue",
  302. value: "dictValue"
  303. }
  304. },
  305. {
  306. label: "收款说明",
  307. prop: "paymentTypeDescription",
  308. span: 8
  309. },
  310. {
  311. label: "币别",
  312. prop: "currency",
  313. span: 8,
  314. type: "select",
  315. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  316. props: {
  317. label: "dictValue",
  318. value: "dictValue"
  319. }
  320. },
  321. {
  322. label: "汇率",
  323. prop: "exchangeRate",
  324. span: 8,
  325. slot: true
  326. },
  327. {
  328. label: "备注",
  329. prop: "orderRemark",
  330. type: "textarea",
  331. minRows: 2,
  332. span: 16
  333. }
  334. ]
  335. },
  336. treeOption: {
  337. nodeKey: "id",
  338. lazy: true,
  339. treeLoad: function(node, resolve) {
  340. const parentId = node.level === 0 ? 0 : node.data.id;
  341. getDeptLazyTree(parentId).then(res => {
  342. resolve(
  343. res.data.data.map(item => {
  344. return {
  345. ...item,
  346. leaf: !item.hasChildren
  347. };
  348. })
  349. );
  350. });
  351. },
  352. addBtn: false,
  353. menu: false,
  354. size: "small",
  355. props: {
  356. label: "title",
  357. value: "value",
  358. children: "children"
  359. }
  360. },
  361. page: {
  362. pageSize: 10,
  363. currentPage: 1,
  364. total: 0
  365. },
  366. loading: false,
  367. goodsOption: goodsOption,
  368. data: [],
  369. goodsList: [],
  370. selectionList: [],
  371. treeDeptId: null,
  372. orderFeesList: []
  373. };
  374. },
  375. props: {
  376. detailData: {
  377. type: Object
  378. }
  379. },
  380. components: {
  381. reportDialog,
  382. feeInfo
  383. },
  384. async created() {
  385. this.tableOption = await this.getColumnData(
  386. this.getColumnName(13),
  387. tableOption
  388. );
  389. if (this.detailData.id) {
  390. this.getDetail(this.detailData.id);
  391. }
  392. let _this = this;
  393. this.tableOption.column.forEach(e => {
  394. if (e.prop == "taxRate") {
  395. e.formatter = function(row) {
  396. return _this.textFormat(
  397. Number(row.taxRate ? row.taxRate : 0) / 100,
  398. "0.00%"
  399. );
  400. };
  401. }
  402. if (e.prop == "amount" || e.prop == "price") {
  403. e.formatter = function(row) {
  404. return _this.textFormat(
  405. Number(row.amount ? row.amount : 0),
  406. "#,##0.00"
  407. );
  408. };
  409. }
  410. });
  411. getPorts().then(res => {
  412. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  413. this.findObject(this.option.column, "portOfDestination").dicData =
  414. res.data;
  415. });
  416. },
  417. methods: {
  418. rateChange(row) {
  419. if (row >= 100) {
  420. this.form.exchangeRate = 0;
  421. this.$message.error("汇率不能超过100%");
  422. }
  423. },
  424. rowSave(row) {
  425. this.$set(row, "$cellEdit", false);
  426. },
  427. importGoods() {
  428. this.selectionList.forEach(e => {
  429. this.data.push({
  430. itemId: e.id,
  431. code: e.code,
  432. cname: e.cname,
  433. priceCategory: e.goodsTypeName,
  434. itemUrl: e.url,
  435. itemProp: null,
  436. itemDescription: null,
  437. itemType: null,
  438. orderQuantity: 0,
  439. tradeTerms: null,
  440. price: 0,
  441. amount: 0,
  442. taxRate: 0,
  443. unit: e.unit,
  444. remarks: null,
  445. $cellEdit: true
  446. });
  447. });
  448. this.dialogVisible = false;
  449. },
  450. closeGoods() {
  451. this.selectionList = [];
  452. this.treeDeptId = "";
  453. },
  454. selectionChange(list) {
  455. this.selectionList = list;
  456. },
  457. rowClick(row) {
  458. this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
  459. },
  460. nodeClick(data) {
  461. this.treeDeptId = data.id;
  462. this.page.currentPage = 1;
  463. this.onLoad(this.page);
  464. },
  465. //费用查询
  466. onLoad(page, params = {}) {
  467. this.loading = true;
  468. getGoods(page.currentPage, page.pageSize, this.treeDeptId).then(res => {
  469. const data = res.data.data;
  470. this.page.total = data.total;
  471. this.goodsList = data.records;
  472. this.loading = false;
  473. if (this.page.total) {
  474. this.goodsOption.height = window.innerHeight - 550;
  475. } else {
  476. this.goodsOption.height = window.innerHeight - 475;
  477. }
  478. });
  479. },
  480. getDetail(id) {
  481. detail(id).then(res => {
  482. this.form = res.data.data;
  483. this.data = res.data.data.itemsVOList;
  484. this.orderFeesList = res.data.data.orderFeesList;
  485. this.configuration.dicData = this.form.corpsName;
  486. });
  487. },
  488. //修改提交触发
  489. editCustomer() {
  490. this.$refs["form"].validate((valid, done) => {
  491. done();
  492. if (valid) {
  493. let orderFeesList = this.$refs.feeInfo.submitData();
  494. for (let i = 0; i < orderFeesList.length; i++) {
  495. if (orderFeesList[i].corpId == null) {
  496. return this.$message.error(`请输入第${i + 1}行的结算中心`);
  497. }
  498. if (orderFeesList[i].price == 0) {
  499. return this.$message.error(`请正确输入第${i + 1}行的价格`);
  500. }
  501. if (orderFeesList[i].quantity == 0) {
  502. return this.$message.error(`请正确输入第${i + 1}行的数量`);
  503. }
  504. }
  505. submit({
  506. id: this.form.id,
  507. orderFeesList: orderFeesList
  508. }).then(res => {
  509. this.$message.success(this.form.id ? "修改成功" : "提交成功");
  510. });
  511. } else {
  512. return false;
  513. }
  514. });
  515. },
  516. //返回列表
  517. backToList() {
  518. this.$emit("goBack");
  519. },
  520. onClose(val) {
  521. this.switchDialog = val;
  522. },
  523. async saveColumn() {
  524. const inSave = await this.saveColumnData(
  525. this.getColumnName(13),
  526. this.tableOption
  527. );
  528. if (inSave) {
  529. this.$message.success("保存成功");
  530. //关闭窗口
  531. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  532. }
  533. }
  534. }
  535. };
  536. </script>
  537. <style lang="scss" scoped>
  538. .customer-head {
  539. position: fixed;
  540. top: 105px;
  541. width: 100%;
  542. margin-left: -10px;
  543. height: 62px;
  544. background: #ffffff;
  545. box-shadow: 0 4px 12px 0px rgba(232, 232, 235, 1);
  546. z-index: 999;
  547. }
  548. .customer-back {
  549. cursor: pointer;
  550. line-height: 62px;
  551. font-size: 16px;
  552. color: #323233;
  553. font-weight: 400;
  554. }
  555. .back-icon {
  556. line-height: 64px;
  557. font-size: 20px;
  558. margin-right: 8px;
  559. }
  560. .copy-customer-btn {
  561. position: fixed;
  562. right: 140px;
  563. top: 115px;
  564. }
  565. .add-customer-btn {
  566. position: fixed;
  567. right: 36px;
  568. top: 115px;
  569. }
  570. ::v-deep .el-form-item {
  571. margin-bottom: 8px;
  572. }
  573. ::v-deep .el-form-item__error {
  574. display: none;
  575. }
  576. ::v-deep .select-component {
  577. display: flex;
  578. }
  579. </style>