detailsPage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  7. @click="backToList">返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button type="primary" size="small" @click="editCustomer">
  12. 保存数据
  13. </el-button>
  14. </div>
  15. </div>
  16. <!-- <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle> -->
  17. <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
  18. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  19. <template slot="corpId">
  20. <ypj-corp v-model="form.corpId" :disabled="detailData.status == 1" @getCorpData="getCorpData"
  21. :dataInfo="true"></ypj-corp>
  22. </template>
  23. </avue-form>
  24. </trade-card>
  25. <trade-card title="商品信息" v-loading="loadingBtn">
  26. <avue-form ref="form" class="trading-form" v-model="form" :option="option2">
  27. <template slot="thisUsedProfit">
  28. <el-input-number v-model="form.thisUsedProfit" @change="amountChange" placeholder="请输入" size="small"
  29. :controls="false" style="width:100%;"></el-input-number>
  30. </template>
  31. </avue-form>
  32. <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
  33. @resetColumn="resetColumn" :cell-style="cellStyle" @row-save="rowSave" @row-update="addUpdate">
  34. <template slot="headerSerial">
  35. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  36. :disabled="detailData.status == 1" circle></el-button>
  37. </template>
  38. <template slot="cname" slot-scope="{ row, index }">
  39. <span style="display:flex">
  40. <el-select v-model="row.cname" placeholder="请选择" size="small" filterable
  41. @change="cnameChange(row, index)">
  42. <el-option v-for="item in goodsoptions" :key="item.itemId" :label="item.cname" :value="item.cname">
  43. </el-option>
  44. </el-select>
  45. </span>
  46. </template>
  47. <template slot="storageInQuantity" slot-scope="{ row, index }">
  48. <el-input-number v-if="row.$cellEdit" v-model="row.storageInQuantity" @change="countChange(row)" placeholder="请输入"
  49. size="small" :controls="false" style="width:100%;"></el-input-number>
  50. <span v-else>{{ row.storageInQuantity }}</span>
  51. </template>
  52. <template slot="price" slot-scope="{ row, index }">
  53. <el-input-number v-if="row.$cellEdit" v-model="row.price" @change="countChange(row)" placeholder="请输入"
  54. size="small" :controls="false" style="width:100%;"></el-input-number>
  55. <span v-else>{{ row.price }}</span>
  56. </template>
  57. <template slot="purchaseAmount" slot-scope="{ row, index }">
  58. <el-input-number v-if="row.$cellEdit" v-model="row.purchaseAmount" @change="countChange(row)" placeholder="请输入"
  59. size="small" :controls="false" style="width:100%;"></el-input-number>
  60. <span v-else>{{ row.purchaseAmount }}</span>
  61. </template>
  62. <template slot="menu" slot-scope="{ row, index }">
  63. <el-button size="small" type="text" @click="rowCell(row, index)">{{
  64. row.$cellEdit ? "保存" : "修改"
  65. }}</el-button>
  66. <el-button size="small" type="text" @click="rowDel(row, index)">删除
  67. </el-button>
  68. </template>
  69. </avue-crud>
  70. </trade-card>
  71. <fee-info :data="settlementList" :form="form" :detailData="detailData" v-loading="loadingBtn"></fee-info>
  72. <containerTitle title="上传附件"></containerTitle>
  73. <c-upload v-loading="loadingBtn" typeUpload="CD"
  74. deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="orderFilesList" display
  75. :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>
  76. <el-dialog :title="addressTitle" v-dialogDrag :visible.sync="addressVisible" class="avue-dialog avue-dialog--top"
  77. width="50%" append-to-body>
  78. <span>
  79. <el-tabs v-model="activeName">
  80. <el-tab-pane label="客户地址" name="first">
  81. <avue-form class="trading-form" v-model="form2" :option="optiontabs1"></avue-form>
  82. </el-tab-pane>
  83. <el-tab-pane label="物流地址" name="second">
  84. <avue-form class="trading-form" v-model="form3" :option="optiontabs2"></avue-form>
  85. </el-tab-pane>
  86. </el-tabs>
  87. </span>
  88. <div class="avue-dialog__footer">
  89. <el-button @click="addressVisible = false">取 消</el-button>
  90. <el-button @click="addressVisible = false" type="primary">确 定</el-button>
  91. </div>
  92. </el-dialog>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. import { optionList } from "./js/optionList";
  98. import { getDetails, submit, getCorpDetails, remove, getGoodsList } from "@/api/basicData/salesOrder";
  99. import feeInfo from "./components/feeInfo.vue";
  100. import { multiply, sum, subtract } from "@/util/calculate";
  101. export default {
  102. name: "index",
  103. data() {
  104. return {
  105. activeName: 'first',
  106. loadingBtn: false,
  107. addressTitle: null,
  108. addressVisible: false,
  109. form: {},
  110. form2: {
  111. },
  112. form3: {
  113. },
  114. data: [],
  115. option: {
  116. menuBtn: false,
  117. labelWidth: 90,
  118. column: [
  119. {
  120. label: "客户名称",
  121. prop: "corpId",
  122. rules: [
  123. {
  124. required: true,
  125. message: "",
  126. trigger: "blur"
  127. }
  128. ],
  129. span: 8,
  130. },
  131. {
  132. label: "送货地址",
  133. prop: "arrivalAddress",
  134. type: 'select',
  135. dicData: [],
  136. props: {
  137. label: 'detailedAddress',
  138. value: 'detailedAddress'
  139. },
  140. allowCreate: true,
  141. filterable: true,
  142. span: 16,
  143. },
  144. {
  145. label: "销售日期",
  146. prop: "businesDate",
  147. type: "date",
  148. format: "yyyy-MM-dd",
  149. valueFormat: "yyyy-MM-dd 00:00:00",
  150. span: 8,
  151. },
  152. {
  153. label: "计划收款日期",
  154. prop: "advanceCollectionDate",
  155. type: "date",
  156. format: "yyyy-MM-dd",
  157. valueFormat: "yyyy-MM-dd 00:00:00",
  158. span: 8,
  159. },
  160. {
  161. label: "送货日期",
  162. prop: "requiredDeliveryDate",
  163. type: "date",
  164. format: "yyyy-MM-dd",
  165. valueFormat: "yyyy-MM-dd 00:00:00",
  166. span: 8,
  167. },
  168. {
  169. label: "备注",
  170. prop: "orderRemark",
  171. placeholder: "打印时显示",
  172. type: "textarea",
  173. minRows: 3,
  174. span: 24,
  175. }
  176. ]
  177. },
  178. option2: {
  179. menuBtn: false,
  180. labelWidth: 70,
  181. column: [
  182. {
  183. label: "税率",
  184. prop: "exchangeRate",
  185. type: "select",
  186. props: {
  187. label: "dictValue",
  188. value: "dictKey"
  189. },
  190. dicUrl: "/api/blade-system/dict-biz/dictionary?code=tax_rate",
  191. span: 4,
  192. },
  193. {
  194. label: "订单金额",
  195. prop: "purchaseAmount",
  196. disabled: true,
  197. span: 4,
  198. },
  199. {
  200. label: "优惠金额",
  201. prop: "thisUsedProfit",
  202. span: 4,
  203. },
  204. {
  205. label: "合同金额",
  206. prop: "orderAmount",
  207. disabled: true,
  208. offset: 8,
  209. span: 4,
  210. }
  211. ]
  212. },
  213. optiontabs1: {
  214. menuBtn: false,
  215. labelWidth: 90,
  216. column: [
  217. {
  218. label: "简称",
  219. prop: "a",
  220. type: "select",
  221. span: 24,
  222. },
  223. {
  224. label: "地址",
  225. prop: "b",
  226. type: "select",
  227. span: 24,
  228. },
  229. {
  230. label: "详细地址",
  231. prop: "c",
  232. span: 24,
  233. },
  234. {
  235. label: "邮编",
  236. prop: "d",
  237. span: 24,
  238. },
  239. {
  240. label: "备注",
  241. prop: "e",
  242. type: 'textarea',
  243. minRows: 3,
  244. span: 24,
  245. },
  246. {
  247. label: "地址智能识别",
  248. prop: "ad",
  249. placeholder: "例:上海市徐汇区枫林街道斜土路100号",
  250. type: "textarea",
  251. minRows: 3,
  252. span: 24,
  253. }
  254. ]
  255. },
  256. optiontabs2: {
  257. menuBtn: false,
  258. labelWidth: 80,
  259. column: [
  260. {
  261. label: "目的地",
  262. prop: "a",
  263. type: "select",
  264. rules: [
  265. {
  266. required: true,
  267. message: "",
  268. trigger: "blur"
  269. }
  270. ],
  271. span: 24,
  272. },
  273. {
  274. label: "物流公司",
  275. prop: "b",
  276. span: 24,
  277. },
  278. {
  279. label: "电话",
  280. prop: "c",
  281. span: 24,
  282. },
  283. {
  284. label: "地址",
  285. prop: "d",
  286. span: 24,
  287. },
  288. {
  289. label: "详细地址",
  290. prop: "e",
  291. span: 24,
  292. },
  293. {
  294. label: "邮编",
  295. prop: "f",
  296. span: 24,
  297. },
  298. {
  299. label: "备注",
  300. prop: "remarks",
  301. type: "textarea",
  302. minRows: 3,
  303. span: 24,
  304. },
  305. {
  306. label: "地址智能识别",
  307. prop: "g",
  308. type: "textarea",
  309. minRows: 3,
  310. span: 24,
  311. }
  312. ]
  313. },
  314. optionList: {},
  315. goodsoptions: [],
  316. settlementList: [],
  317. };
  318. },
  319. props: {
  320. detailData: {
  321. type: Object
  322. }
  323. },
  324. components: {
  325. feeInfo,
  326. },
  327. async created() {
  328. this.optionList = await this.getColumnData(
  329. this.getColumnName(212),
  330. optionList
  331. );
  332. if (this.detailData.id) {
  333. this.getDetail(this.detailData.id);
  334. }
  335. if (this.detailData.status == 1) {
  336. this.option.disabled = true;
  337. }
  338. this.getAllWorkDicts()
  339. getGoodsList(1, 10).then(res => {
  340. if (res.data.data.total > 0) {
  341. this.goodsoptions = res.data.data.records;
  342. if (Math.ceil(res.data.data.total / 10) > 1) {
  343. for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
  344. getGoodsList(i, 10).then(e => {
  345. this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
  346. });
  347. }
  348. }
  349. }
  350. });
  351. },
  352. methods: {
  353. getAllWorkDicts() {
  354. this.getWorkDicts("unit").then(res => {
  355. this.findObject(this.optionList.column, "unit").dicData = res.data.data;
  356. });
  357. this.$refs.crud.init();
  358. },
  359. cellStyle() {
  360. return "padding:0;height:40px;";
  361. },
  362. cnameChange(row) {
  363. console.log(row)
  364. if (row.cname) {
  365. this.goodsoptions.forEach(e => {
  366. if (e.cname == row.cname) {
  367. row.unit = e.unit
  368. row.price = e.standardPrice
  369. row.storageInQuantity = 1
  370. row.amount = e.standardPrice
  371. row.purchaseAmount = e.purchasePrice
  372. row.storageAmount = e.purchasePrice
  373. }
  374. })
  375. } else {
  376. row.unit = null
  377. row.price = null
  378. row.purchaseAmount = null
  379. }
  380. },
  381. amountChange() {
  382. let val = 0
  383. this.data.forEach(e => {
  384. val = sum(val, e.amount)
  385. this.form.purchaseAmount = val
  386. this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  387. })
  388. },
  389. countChange(row) {
  390. row.amount = multiply(row.price, row.storageInQuantity)
  391. row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
  392. },
  393. getDetail(id) {
  394. this.loadingBtn = true
  395. getDetails({ id: id })
  396. .then(res => {
  397. this.form = res.data.data;
  398. this.data = res.data.data.orderItemsList;
  399. this.settlementList = res.data.data.settlementList
  400. this.getAddress(res.data.data)
  401. })
  402. .finally(() => {
  403. this.loadingBtn = false;
  404. });
  405. },
  406. getCorpData(row) {
  407. console.log(row)
  408. this.findObject(this.option.column, "arrivalAddress").dicData = row.corpsAddrList;
  409. // this.form.corpName = row.cname
  410. },
  411. getAddress(row) {
  412. getCorpDetails({ id: row.corpId }).then(res => {
  413. this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
  414. })
  415. },
  416. addRow() {
  417. this.data.push({ $cellEdit: true })
  418. },
  419. rowCell(row, index) {
  420. this.$refs.crud.rowCell(row, index)
  421. },
  422. rowSave(form, done) {
  423. done()
  424. },
  425. addUpdate(form, index, done, loading) {
  426. done()
  427. },
  428. rowDel(row, index) {
  429. this.$confirm("确定删除数据?", {
  430. confirmButtonText: "确定",
  431. cancelButtonText: "取消",
  432. type: "warning"
  433. }).then(() => {
  434. if (row.id) {
  435. remove(row.id).then(res => {
  436. this.$message({
  437. type: "success",
  438. message: "删除成功!"
  439. });
  440. this.data.splice(index, 1);
  441. });
  442. } else {
  443. this.$message({
  444. type: "success",
  445. message: "删除成功!"
  446. });
  447. this.data.splice(index, 1);
  448. }
  449. });
  450. },
  451. //修改提交触发
  452. editCustomer() {
  453. this.$refs["form"].validate((valid, done) => {
  454. done();
  455. if (valid) {
  456. this.loadingBtn = true;
  457. submit({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList })
  458. .then(res => {
  459. this.$message.success("保存成功");
  460. this.form = res.data.data;
  461. this.data = res.data.data.orderItemsList;
  462. this.settlementList = res.data.data.settlementList
  463. })
  464. .finally(() => {
  465. this.loadingBtn = false;
  466. });
  467. } else {
  468. return false;
  469. }
  470. });
  471. },
  472. async saveColumn() {
  473. const inSave = await this.saveColumnData(
  474. this.getColumnName(212),
  475. this.optionList
  476. );
  477. if (inSave) {
  478. this.$nextTick(() => {
  479. this.$refs.crud.doLayout();
  480. });
  481. this.$message.success("保存成功");
  482. //关闭窗口
  483. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  484. }
  485. },
  486. async resetColumn() {
  487. this.optionList = optionList;
  488. const inSave = await this.delColumnData(
  489. this.getColumnName(212),
  490. optionList
  491. );
  492. if (inSave) {
  493. this.$nextTick(() => {
  494. this.$refs.crud.doLayout();
  495. });
  496. this.getAllWorkDicts()
  497. this.$message.success("重置成功");
  498. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  499. }
  500. },
  501. //返回列表
  502. backToList() {
  503. this.$emit("goBack");
  504. }
  505. },
  506. watch: {
  507. data: function (rows) {
  508. let val = 0
  509. rows.forEach(e => {
  510. val = sum(val, e.amount)
  511. this.form.purchaseAmount = val
  512. this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  513. })
  514. }
  515. }
  516. };
  517. </script>
  518. <style lang="scss" scoped>
  519. .trading-form ::v-deep .el-form-item {
  520. margin-bottom: 8px !important;
  521. }
  522. ::v-deep .el-dialog__body {
  523. padding: 0px 20px 15px 20px;
  524. }
  525. ::v-deep .el-form-item__error {
  526. display: none !important;
  527. }
  528. .img-form ::v-deep .el-form-item {
  529. height: 150px;
  530. line-height: 150px;
  531. margin-bottom: 8px !important;
  532. }
  533. .img-form ::v-deep .avue-upload__icon {
  534. font-size: 20px;
  535. width: 150px;
  536. height: 150px;
  537. line-height: 150px;
  538. }
  539. ::v-deep .el-table .cell {
  540. padding: 0 2px !important;
  541. }
  542. ::v-deep .avue-crud .el-table .el-form-item__label {
  543. left: -1px;
  544. }
  545. .addressTabs {
  546. display: flex;
  547. justify-content: center;
  548. span {
  549. width: 100px;
  550. font-size: 18px;
  551. font-weight: 600;
  552. text-align: center;
  553. }
  554. }
  555. </style>