detailsPage.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  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 v-if="detailData.check" type="primary" size="small" class="el-button--small-yh"
  12. @click.stop="openCheckDialog">
  13. 审批
  14. </el-button>
  15. <!--<el-button type="primary" size="small" v-if="form.confirmStatus == 1" @click="newAddfun">新建销售单-->
  16. <!--</el-button>-->
  17. <el-button type="warning" size="small" v-if="form.confirmStatus == 1" @click.stop="clickPayment">付款
  18. </el-button>
  19. <el-button type="info" icon="el-icon-printer" size="small" @click.stop="openReport()">报表打印
  20. </el-button>
  21. <el-button type="primary" size="small" v-if="detailData.status == 1 && form.confirmStatus == 0"
  22. class="el-button--small-yh " @click.stop="openEdit">编辑
  23. </el-button>
  24. <el-button type="primary" size="small" v-if="!form.id && detailData.status != 1" @click="editCustomer">
  25. 保存数据
  26. </el-button>
  27. <!--<el-button type="primary" size="small" v-if="form.id && detailData.status != 1 && form.confirmStatus == 0"-->
  28. <!-- @click="fixSave">-->
  29. <!-- 保存数据-->
  30. <!--</el-button>-->
  31. <el-button type="primary" size="small" v-if="form.id && detailData.status != 1 && form.confirmStatus == 0"
  32. @click="submit">
  33. 提交
  34. </el-button>
  35. <el-button type="primary" size="small" v-if="form.confirmStatus == 1" @click="revokeOrder">
  36. 撤销
  37. </el-button>
  38. </div>
  39. </div>
  40. <!-- <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle> -->
  41. <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
  42. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  43. <template slot="corpId">
  44. <crop-select v-model="form.corpId" corpType="KH" :disabled="detailData.status == 1"
  45. @getCorpData="getCorpData"></crop-select>
  46. </template>
  47. <template slot="storageId">
  48. <el-select v-model="form.storageId" placeholder="请选择" size="small" filterable @change="storageChange"
  49. :disabled="detailData.status == 1 || data.length > 0">
  50. <el-option v-for="item in storageoptions" :key="item.id" :label="item.cname" :value="item.id">
  51. </el-option>
  52. </el-select>
  53. </template>
  54. </avue-form>
  55. </trade-card>
  56. <trade-card title="商品信息" v-loading="loadingBtn">
  57. <avue-form ref="option2form" class="trading-form" v-model="form" :option="option2">
  58. <template slot="thisUsedProfit">
  59. <el-input-number v-model="form.thisUsedProfit" :disabled="detailData.status == 1"
  60. placeholder="请输入" size="small" :controls="false" style="width:100%;"
  61. @change="thisUsedchange" ></el-input-number>
  62. <!--@change="amountChange"-->
  63. </template>
  64. <template slot="memberBalance">
  65. <el-input-number v-model="form.memberBalance" :disabled="detailData.status == 1"
  66. placeholder="请输入" size="small" :controls="false"
  67. @change="memberchange"></el-input-number>
  68. <span style="margin-left: 10px">余额:{{balanceAmounts}}</span>
  69. </template>
  70. </avue-form>
  71. <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
  72. @resetColumn="resetColumn" :cell-style="cellStyle">
  73. <template slot="headerSerial">
  74. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
  75. :disabled="detailData.status == 1" circle></el-button>
  76. </template>
  77. <template slot="cname" slot-scope="{ row, index }">
  78. <el-select v-if="row.$cellEdit" v-model="row.cname" placeholder="请选择" size="small" filterable
  79. @change="cnameChange(row, index)">
  80. <el-option v-for="item in goodsoptions" :key="item.itemId" :label="item.cname" :value="item.cname"
  81. :disabled="item.status == 1">
  82. </el-option>
  83. </el-select>
  84. <span v-else>{{ row.cname }}</span>
  85. </template>
  86. <template slot="unitHeader" slot-scope="{column}">
  87. <span style="color: #409EFF;cursor: pointer" @click.stop="$refs.dictbiz.open()">单位
  88. </span>
  89. </template>
  90. <template slot="storageInQuantity" slot-scope="{ row, index }">
  91. <el-input-number v-if="row.$cellEdit" v-model="row.storageInQuantity" @change="countChange(row)"
  92. placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input-number>
  93. <span v-else>{{ row.storageInQuantity }}</span>
  94. </template>
  95. <template slot="price" slot-scope="{ row, index }">
  96. <el-input-number v-if="row.$cellEdit" v-model="row.price" @change="countChange(row)" placeholder="请输入"
  97. size="small" :controls="false" style="width:100%;"></el-input-number>
  98. <span v-else>{{ row.price }}</span>
  99. </template>
  100. <template slot="purchaseAmount" slot-scope="{ row, index }">
  101. <el-input-number v-if="row.$cellEdit" v-model="row.purchaseAmount" @change="countChange(row)"
  102. placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input-number>
  103. <span v-else>{{ row.purchaseAmount }}</span>
  104. </template>
  105. <template slot="menu" slot-scope="{ row, index }">
  106. <el-button size="small" type="text" :disabled="detailData.status == 1" @click="rowCell(row, index)">{{
  107. row.$cellEdit ? "保存" : "修改"
  108. }}</el-button>
  109. <el-button size="small" type="text" :disabled="detailData.status == 1" @click="rowDel(row, index)">删除
  110. </el-button>
  111. </template>
  112. </avue-crud>
  113. </trade-card>
  114. <fee-info ref="feeInfo" :data="settlementList" :form="form" :detailData="detailData" @getPay="getPay"
  115. v-loading="loadingBtn">
  116. </fee-info>
  117. <containerTitle title="上传附件"></containerTitle>
  118. <c-upload v-loading="loadingBtn" typeUpload="CD"
  119. deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="orderFilesList" display
  120. :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>
  121. <el-dialog :title="addressTitle" v-dialogDrag :visible.sync="addressVisible" class="avue-dialog avue-dialog--top"
  122. width="50%" append-to-body>
  123. <span>
  124. <el-tabs v-model="activeName">
  125. <el-tab-pane label="客户地址" name="first">
  126. <avue-form class="trading-form" v-model="form2" :option="optiontabs1"></avue-form>
  127. </el-tab-pane>
  128. <el-tab-pane label="物流地址" name="second">
  129. <avue-form class="trading-form" v-model="form3" :option="optiontabs2"></avue-form>
  130. </el-tab-pane>
  131. </el-tabs>
  132. </span>
  133. <div class="avue-dialog__footer">
  134. <el-button @click="addressVisible = false">取 消</el-button>
  135. <el-button @click="addressVisible = false" type="primary">确 定</el-button>
  136. </div>
  137. </el-dialog>
  138. <dictbiz-dialog ref="dictbiz" title="添加单位" code="unit" parentId="1585962784498225154"
  139. @closed="getAllWorkDicts">
  140. </dictbiz-dialog>
  141. <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="配件系统-销售单" @onClose="onClose()">
  142. </report-dialog>
  143. </div>
  144. <el-dialog append-to-body title="审批" class="el-dialogDeep" :visible.sync="checkDialog" width="50%"
  145. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
  146. <check :checkData="checkData" :checkDetail="false" :idList="[]" @choceCheckFun="choceCheckFun">
  147. </check>
  148. </el-dialog>
  149. <!--付款的弹窗-->
  150. <!--<el-dialog-->
  151. <!-- title="付款"-->
  152. <!-- :visible.sync="paymentVisible"-->
  153. <!-- append-to-body-->
  154. <!-- :close-on-click-modal="false"-->
  155. <!-- :destroy-on-close="true"-->
  156. <!-- :close-on-press-escape="false"-->
  157. <!-- v-dialog-drag-->
  158. <!-- width="40%"-->
  159. <!-- :before-close="paymentClose">-->
  160. <!-- <div>-->
  161. <!-- <el-form ref="form" label-width="100px" size="mini">-->
  162. <!-- <el-form-item label="总支付金额">-->
  163. <!-- {{form.purchaseAmount}}-->
  164. <!-- </el-form-item>-->
  165. <!-- <el-form-item label="会员卡余额">-->
  166. <!-- {{balanceAmounts}}-->
  167. <!-- </el-form-item>-->
  168. <!-- <el-form-item label="会员卡支付金额">-->
  169. <!-- <el-input type="number" v-model="form.memberBalance" @change="memberBalancechange"></el-input>-->
  170. <!-- </el-form-item>-->
  171. <!-- <el-form-item label="现金支付金额">-->
  172. <!-- <el-input type="number" v-model="form.wechatpayAmount"></el-input>-->
  173. <!-- </el-form-item>-->
  174. <!-- </el-form>-->
  175. <!-- </div>-->
  176. <!-- <span slot="footer" class="dialog-footer">-->
  177. <!-- <el-button @click="paymentVisible = false">取 消</el-button>-->
  178. <!-- <el-button type="primary" @click="paymentVisible = false">确 定</el-button>-->
  179. <!-- </span>-->
  180. <!--</el-dialog>-->
  181. </div>
  182. </template>
  183. <script>
  184. import {optionList} from "./js/optionList";
  185. import {
  186. getDetails,
  187. submit,
  188. getCorpDetails,
  189. remove,
  190. getAllgoods,
  191. save,
  192. fixSave,
  193. revoke,
  194. collectPayment,
  195. getStoragelist,
  196. offset,
  197. obtainPrice
  198. } from "@/api/basicData/salesOrder";
  199. import feeInfo from "./components/feeInfo.vue";
  200. import reportDialog from "@/components/report-dialog/main";
  201. import { multiply, sum, subtract } from "@/util/calculate";
  202. import {fdatasync} from "fs";
  203. import check from "@/components/check/check";
  204. export default {
  205. name: "index",
  206. data() {
  207. return {
  208. // 付款的弹窗开启和关闭
  209. paymentVisible:false,
  210. checkDialog: false,
  211. checkData: {},
  212. switchDialog: false,
  213. activeName: 'first',
  214. loadingBtn: false,
  215. addressTitle: null,
  216. addressVisible: false,
  217. form: {},
  218. form2: {},
  219. form3: {},
  220. data: [],
  221. option: {
  222. menuBtn: false,
  223. labelWidth: 90,
  224. disabled: false,
  225. column: [
  226. {
  227. label: "客户名称",
  228. prop: "corpId",
  229. rules: [
  230. {
  231. required: true,
  232. message: "",
  233. trigger: "blur"
  234. }
  235. ],
  236. span: 8,
  237. },
  238. {
  239. label: "销售单号",
  240. prop: "sysNo",
  241. disabled: true,
  242. span: 8,
  243. },
  244. {
  245. label: "退款单号",
  246. prop: "srcOrderNo",
  247. disabled: true,
  248. span: 8,
  249. }, {
  250. label: "订单来源",
  251. prop: "orderSource",
  252. disabled: true,
  253. type: 'select',
  254. dataType: 'number',
  255. dicData: [
  256. {
  257. label: "APP/PC",
  258. value: 1
  259. },
  260. {
  261. label: "小程序",
  262. value: 2
  263. }],
  264. props: {
  265. label: 'label',
  266. value: 'value'
  267. },
  268. span: 8,
  269. }, {
  270. label: "联系人",
  271. prop: "corpAttn",
  272. disabled: true,
  273. span: 8,
  274. }, {
  275. label: "联系电话",
  276. prop: "corpTel",
  277. disabled: true,
  278. span: 8,
  279. }, {
  280. label: "送货地址",
  281. prop: "arrivalAddress",
  282. type: 'select',
  283. dicData: [],
  284. props: {
  285. label: 'detailedAddress',
  286. value: 'detailedAddress'
  287. },
  288. allowCreate: true,
  289. filterable: true,
  290. span: 16,
  291. }, {
  292. label: "销售日期",
  293. prop: "businesDate",
  294. type: "datetime",
  295. format: "yyyy-MM-dd HH:mm:ss",
  296. valueFormat: "yyyy-MM-dd HH:mm:ss",
  297. span: 8,
  298. }, {
  299. label: "计划收款日期",
  300. prop: "advanceCollectionDate",
  301. type: "date",
  302. format: "yyyy-MM-dd",
  303. valueFormat: "yyyy-MM-dd HH:mm:ss",
  304. span: 8,
  305. }, {
  306. label: "送货日期",
  307. prop: "requiredDeliveryDate",
  308. type: "date",
  309. format: "yyyy-MM-dd",
  310. valueFormat: "yyyy-MM-dd 00:00:00",
  311. span: 8,
  312. }, {
  313. label: "快递公司",
  314. prop: "courierCorporation",
  315. disabled: true,
  316. span: 8,
  317. },
  318. {
  319. label: "快递单号",
  320. prop: "courierNumber",
  321. disabled: true,
  322. span: 8,
  323. },
  324. {
  325. label: "仓库",
  326. prop: "storageId",
  327. rules: [
  328. {
  329. required: true,
  330. message: "",
  331. trigger: "blur"
  332. }
  333. ],
  334. span: 8,
  335. },
  336. {
  337. label: "备注",
  338. prop: "orderRemark",
  339. placeholder: "打印时显示",
  340. type: "textarea",
  341. minRows: 3,
  342. span: 24,
  343. }
  344. ]
  345. },
  346. option2: {
  347. menuBtn: false,
  348. labelWidth: 80,
  349. disabled: false,
  350. column: [
  351. {
  352. label: "订单金额",
  353. prop: "purchaseAmount",
  354. disabled: true,
  355. span: 4,
  356. },
  357. {
  358. label: "优惠金额",
  359. prop: "thisUsedProfit",
  360. span: 4,
  361. },
  362. {
  363. label: "会员卡金额",
  364. prop: "memberBalance",
  365. span: 8,
  366. },
  367. {
  368. label: "应收金额",
  369. prop: "balanceAmount",
  370. disabled: true,
  371. span: 8,
  372. },
  373. {
  374. label: "成本",
  375. prop: "costAmount",
  376. disabled: true,
  377. span: 4,
  378. },
  379. {
  380. label: "毛利",
  381. prop: "grossProfit",
  382. disabled: true,
  383. span: 4,
  384. },
  385. {
  386. label: "税率",
  387. prop: "exchangeRate",
  388. type: "select",
  389. props: {
  390. label: "dictValue",
  391. value: "dictKey"
  392. },
  393. dicUrl: "/api/blade-system/dict-biz/dictionary?code=tax_rate_xin",
  394. span: 4,
  395. },
  396. {
  397. label: "销售总数量",
  398. prop: "storageQuantity",
  399. disabled: true,
  400. span: 4,
  401. },
  402. {
  403. label: "已收金额",
  404. prop: "settlmentAmount",
  405. disabled: true,
  406. span: 8,
  407. }
  408. ]
  409. },
  410. optiontabs1: {
  411. menuBtn: false,
  412. labelWidth: 90,
  413. column: [
  414. {
  415. label: "简称",
  416. prop: "a",
  417. type: "select",
  418. span: 24,
  419. },
  420. {
  421. label: "地址",
  422. prop: "b",
  423. type: "select",
  424. span: 24,
  425. },
  426. {
  427. label: "详细地址",
  428. prop: "c",
  429. span: 24,
  430. },
  431. {
  432. label: "邮编",
  433. prop: "d",
  434. span: 24,
  435. },
  436. {
  437. label: "备注",
  438. prop: "e",
  439. type: 'textarea',
  440. minRows: 3,
  441. span: 24,
  442. },
  443. {
  444. label: "地址智能识别",
  445. prop: "ad",
  446. placeholder: "例:上海市徐汇区枫林街道斜土路100号",
  447. type: "textarea",
  448. minRows: 3,
  449. span: 24,
  450. }
  451. ]
  452. },
  453. optiontabs2: {
  454. menuBtn: false,
  455. labelWidth: 80,
  456. column: [
  457. {
  458. label: "目的地",
  459. prop: "a",
  460. type: "select",
  461. rules: [
  462. {
  463. required: true,
  464. message: "",
  465. trigger: "blur"
  466. }
  467. ],
  468. span: 24,
  469. },
  470. {
  471. label: "物流公司",
  472. prop: "b",
  473. span: 24,
  474. },
  475. {
  476. label: "电话",
  477. prop: "c",
  478. span: 24,
  479. },
  480. {
  481. label: "地址",
  482. prop: "d",
  483. span: 24,
  484. },
  485. {
  486. label: "详细地址",
  487. prop: "e",
  488. span: 24,
  489. },
  490. {
  491. label: "邮编",
  492. prop: "f",
  493. span: 24,
  494. },
  495. {
  496. label: "备注",
  497. prop: "remarks",
  498. type: "textarea",
  499. minRows: 3,
  500. span: 24,
  501. },
  502. {
  503. label: "地址智能识别",
  504. prop: "g",
  505. type: "textarea",
  506. minRows: 3,
  507. span: 24,
  508. }
  509. ]
  510. },
  511. optionList: {},
  512. goodsoptions: [],
  513. settlementList: [],
  514. orderFilesList: [],
  515. storageoptions: [],
  516. // 会员卡余额
  517. balanceAmounts:0,
  518. };
  519. },
  520. props: {
  521. detailData: {
  522. type: Object
  523. }
  524. },
  525. components: {
  526. feeInfo,
  527. check,
  528. reportDialog
  529. },
  530. async created() {
  531. // console.log(this.detailData)
  532. this.optionList = await this.getColumnData(
  533. this.getColumnName(212),
  534. optionList
  535. );
  536. if (this.detailData.id) {
  537. this.getDetail(this.detailData.id);
  538. }
  539. if (this.detailData.status == 1) {
  540. this.option.disabled = true;
  541. this.option2.disabled = true;
  542. }
  543. this.getAllWorkDicts()
  544. getAllgoods().then(res => {
  545. this.goodsoptions = []
  546. res.data.data.map(item=>{
  547. if(item.status != 1) {
  548. this.goodsoptions.push(item)
  549. }
  550. })
  551. // this.goodsoptions = res.data.data
  552. });
  553. },
  554. methods: {
  555. // // 会员卡支付金额的监听
  556. // memberBalancechange(){
  557. // if (Number(this.form.memberBalance) < 0) {
  558. // this.form.memberBalance = 0
  559. // }
  560. // this.form.wechatpayAmount = this.form.purchaseAmount - this.form.memberBalance
  561. // },
  562. // 优惠金额的监听
  563. thisUsedchange(){
  564. this.form.memberBalance = this.form.memberBalance?this.form.memberBalance:0
  565. if(Number(this.form.thisUsedProfit) < 0) {
  566. this.$nextTick(()=>{
  567. this.form.thisUsedProfit = 0
  568. })
  569. }
  570. if (Number(this.form.thisUsedProfit) > Number(this.form.purchaseAmount)) {
  571. this.$nextTick(()=>{
  572. this.form.thisUsedProfit = Number(this.form.purchaseAmount)
  573. this.form.memberBalance = 0
  574. this.form.currentAmount = 0
  575. })
  576. }
  577. let sum = Number(this.form.purchaseAmount) - Number(this.form.memberBalance)
  578. if (Number(this.form.thisUsedProfit) > sum){
  579. this.$nextTick(()=>{
  580. console.log(this.form.thisUsedProfit)
  581. this.form.thisUsedProfit = sum
  582. this.form.currentAmount = 0
  583. })
  584. }
  585. this.$nextTick(()=>{
  586. console.log(sum - this.form.thisUsedProfit)
  587. this.form.currentAmount = sum - this.form.thisUsedProfit
  588. })
  589. },
  590. // 会员卡金额的监听
  591. memberchange(){
  592. // change事件发生后触发了dom更新,
  593. // 而数据更改变化是在dom更新之后,
  594. // 这就导致了dom当中挂载的数据值还是更新之前的值,
  595. // 并且此后无刷新控制dom重新渲染的指令,使得chhange方法失效。
  596. // 用$nextTick函数对绑定值进行更改,
  597. // 即在dom初次完成渲染挂载后,修改其值再次触发dom渲染挂载。
  598. this.form.thisUsedProfit = this.form.thisUsedProfit?this.form.thisUsedProfit:0
  599. if (this.form.memberBalance < 0) {
  600. this.$nextTick(()=>{
  601. this.form.memberBalance = 0
  602. })
  603. }
  604. if (this.form.memberBalance > Number(this.balanceAmounts)) {
  605. this.$nextTick(()=>{
  606. this.form.memberBalance = Number(this.balanceAmounts)
  607. })
  608. }
  609. let sum = Number(this.form.purchaseAmount) - Number(this.form.thisUsedProfit)
  610. if (this.form.memberBalance > sum) {
  611. this.$nextTick(()=>{
  612. this.form.memberBalance = sum
  613. })
  614. }
  615. this.$nextTick(()=>{
  616. console.log(sum - this.form.memberBalance)
  617. this.form.currentAmount = sum - this.form.memberBalance
  618. })
  619. },
  620. // 付款点击事件
  621. clickPayment(){
  622. // 和删除一样的接口 显示要付款的现金
  623. this.$confirm(`本次付款需要支付金额为${this.form.currentAmount}`, '提示', {
  624. confirmButtonText: '确定',
  625. cancelButtonText: '取消',
  626. type: 'warning'
  627. }).then(()=>{
  628. let form = {
  629. ...this.form,
  630. orderFilesList: this.orderFilesList
  631. }
  632. collectPayment(form).then(res=>{
  633. console.log(res,632)
  634. })
  635. })
  636. // this.paymentVisible = true
  637. },
  638. // // 付款弹窗的关闭
  639. // paymentClose(){
  640. // this.paymentVisible = false
  641. // },
  642. //打开审核
  643. openCheckDialog() {
  644. this.checkData = this.detailData.check;
  645. this.checkDialog = true;
  646. },
  647. //关闭审核
  648. choceCheckFun() {
  649. this.checkDialog = false;
  650. },
  651. openReport() {
  652. this.switchDialog = !this.switchDialog;
  653. },
  654. onClose(val) {
  655. this.switchDialog = val;
  656. },
  657. getAllWorkDicts() {
  658. this.getWorkDicts("unit").then(res => {
  659. this.findObject(this.optionList.column, "unit").dicData = res.data.data;
  660. });
  661. getStoragelist().then(res => {
  662. this.storageoptions = res.data;
  663. this.findObject(this.optionList.column, "storageId").dicData = res.data;
  664. })
  665. this.$refs.crud.init();
  666. },
  667. cellStyle() {
  668. return "padding:0;height:40px;";
  669. },
  670. cnameChange(row) {
  671. console.log(row,668)
  672. if (row.cname) {
  673. this.goodsoptions.forEach(e => {
  674. if (e.cname == row.cname) {
  675. row.itemId = e.id
  676. row.unit = e.unit
  677. // row.price = e.standardPrice
  678. row.storageInQuantity = 1
  679. row.amount = e.standardPrice
  680. row.purchasePrice = e.purchasePrice
  681. row.storageAmount = e.purchasePrice
  682. }
  683. })
  684. // 根据产品ID和客户id获取产品单价
  685. obtainPrice({
  686. corpId:this.form.corpId,
  687. goodsId:row.itemId
  688. }).then(res=>{
  689. row.price = res.data.data.salesPrice
  690. })
  691. } else {
  692. row.itemId = null
  693. row.unit = null
  694. row.price = null
  695. row.storageInQuantity = null
  696. row.amount = null
  697. row.purchasePrice = null
  698. row.storageAmount = null
  699. }
  700. this.countChange(row)
  701. },
  702. // 之前的优惠金额的监听
  703. amountChange() {
  704. let val = 0
  705. this.data.forEach(e => {
  706. val = sum(val, e.amount)
  707. this.form.purchaseAmount = val
  708. this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  709. })
  710. },
  711. countChange(row) {
  712. row.amount = multiply(row.price, row.storageInQuantity)
  713. row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
  714. let val = 0
  715. this.data.forEach(e => {
  716. val = sum(val, e.amount)
  717. this.form.purchaseAmount = val
  718. this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
  719. })
  720. this.$refs.crud.refreshTable();
  721. },
  722. getDetail(id) {
  723. this.loadingBtn = true
  724. getDetails({ id: id })
  725. .then(res => {
  726. this.form = res.data.data;
  727. this.data = res.data.data.orderItemsList;
  728. this.settlementList = res.data.data.settlementList;
  729. this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
  730. this.getAddress(res.data.data)
  731. }).finally(() => {
  732. this.loadingBtn = false;
  733. });
  734. },
  735. getCorpData(row) {
  736. if (row) {
  737. this.form.corpsName = row.cname
  738. this.form.corpTel = row.tel
  739. getCorpDetails({ id: row.id }).then(res => {
  740. this.balanceAmounts = res.data.data.balanceAmounts
  741. this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
  742. })
  743. } else {
  744. this.form.corpsName = null
  745. this.form.corpTel = null
  746. this.findObject(this.option.column, "arrivalAddress").dicData = []
  747. }
  748. },
  749. storageChange(row) {
  750. // console.log(row)
  751. },
  752. getAddress(row) {
  753. getCorpDetails({ id: row.corpId }).then(res => {
  754. this.balanceAmounts = res.data.data.balanceAmounts
  755. this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
  756. })
  757. if (this.form.billType == "XS"){
  758. this.findObject(this.option.column, "sysNo").label = "销售单号";
  759. this.findObject(this.option.column, "srcOrderNo").label = "退款单号";
  760. }else if (this.form.billType == "XSTH"){
  761. this.findObject(this.option.column, "sysNo").label = "退款单号";
  762. this.findObject(this.option.column, "srcOrderNo").label = "销售单号";
  763. }
  764. },
  765. addRow() {
  766. this.$refs["form"].validate((valid, done) => {
  767. done();
  768. if (valid) {
  769. this.data.push({ $cellEdit: true, storageId: this.form.storageId })
  770. } else {
  771. return false;
  772. }
  773. });
  774. },
  775. rowCell(row, index) {
  776. if (row.$cellEdit == true) {
  777. this.$set(row, "$cellEdit", false);
  778. } else {
  779. this.$set(row, "$cellEdit", true);
  780. }
  781. },
  782. rowDel(row, index) {
  783. this.$confirm("确定删除数据?", {
  784. confirmButtonText: "确定",
  785. cancelButtonText: "取消",
  786. type: "warning"
  787. }).then(() => {
  788. if (row.id) {
  789. remove(row.id).then(res => {
  790. this.$message({
  791. type: "success",
  792. message: "删除成功!"
  793. });
  794. this.data.splice(index, 1);
  795. });
  796. } else {
  797. this.$message({
  798. type: "success",
  799. message: "删除成功!"
  800. });
  801. this.data.splice(index, 1);
  802. }
  803. });
  804. },
  805. getPay(row) {
  806. // this.form = row;
  807. // this.data = row.orderItemsList;
  808. // this.settlementList = row.settlementList
  809. this.getDetail(row.id);
  810. },
  811. // 新建销售单
  812. newAddfun(){
  813. // delete this.form.id
  814. this.$refs.form.resetFields()
  815. this.form = {}
  816. this.$nextTick(() => {
  817. this.$refs.option2form.resetFields()
  818. });
  819. this.data = [];
  820. this.form.confirmStatus = null
  821. this.detailData = []
  822. this.detailData.status = 2
  823. this.settlementList = [];
  824. this.orderFilesList = [];
  825. this.balanceAmount = 0
  826. this.option.disabled = false;
  827. this.option2.disabled = false;
  828. this.$refs.crud.refreshTable();
  829. this.$refs.feeInfo.refreshTable();
  830. // // this.$refs.option2form.resetFields()这个做法其实是重置表单到初始值,不是清空表单,
  831. // // 当表单第一次在页面中渲染时所用的数据就是初始数据,如果修改对象的表单赋值没有放在nextTick中,
  832. // // 就会在表单渲染时就会将这个修改对象作为初始值,
  833. // // 所以出现无效了。
  834. // // 使用nextTick保证表单在第一次渲染时是空值就可以了。
  835. // this.xinjianfasle = true
  836. this.$forceUpdate()
  837. },
  838. //修改提交触发
  839. editCustomer() {
  840. this.$refs["form"].validate((valid, done) => {
  841. done();
  842. if (valid) {
  843. if (this.data.length == 0) {
  844. return this.$message.error('请添加一条商品信息');
  845. }
  846. if (this.settlementList.length > 0) {
  847. for (let i = 0; i < this.settlementList.length; i++) {
  848. if (!this.settlementList[i].id) {
  849. return this.$message.error(`请保存第${i + 1}行的费用明细`);
  850. }
  851. }
  852. }
  853. this.loadingBtn = true;
  854. save({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
  855. .then(res => {
  856. this.$message.success("保存成功");
  857. this.form = res.data.data;
  858. this.data = res.data.data.orderItemsList;
  859. this.settlementList = res.data.data.settlementList;
  860. this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
  861. this.detailData.status = 1
  862. this.option.disabled = true;
  863. this.option2.disabled = true;
  864. this.$refs.crud.refreshTable();
  865. this.$refs.feeInfo.refreshTable();
  866. })
  867. .finally(() => {
  868. this.loadingBtn = false;
  869. });
  870. } else {
  871. return false;
  872. }
  873. });
  874. },
  875. fixSave() {
  876. this.$refs["form"].validate((valid, done) => {
  877. done();
  878. if (valid) {
  879. if (this.data.length == 0) {
  880. return this.$message.error('请添加一条商品信息');
  881. }
  882. if (this.settlementList.length > 0) {
  883. for (let i = 0; i < this.settlementList.length; i++) {
  884. if (!this.settlementList[i].id) {
  885. return this.$message.error(`请保存第${i + 1}行的费用明细`);
  886. }
  887. }
  888. }
  889. this.loadingBtn = true;
  890. fixSave({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
  891. .then(res => {
  892. this.$message.success("修改成功");
  893. this.form = res.data.data;
  894. this.data = res.data.data.orderItemsList;
  895. this.settlementList = res.data.data.settlementList
  896. this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
  897. })
  898. .finally(() => {
  899. this.loadingBtn = false;
  900. });
  901. } else {
  902. return false;
  903. }
  904. });
  905. },
  906. submit() {
  907. this.$refs["form"].validate((valid, done) => {
  908. done();
  909. if (valid) {
  910. if (this.data.length == 0) {
  911. return this.$message.error('请添加一条商品信息');
  912. }
  913. if (this.settlementList.length > 0) {
  914. for (let i = 0; i < this.settlementList.length; i++) {
  915. if (!this.settlementList[i].id) {
  916. return this.$message.error(`请保存第${i + 1}行的费用明细`);
  917. }
  918. }
  919. }
  920. this.loadingBtn = true;
  921. submit({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
  922. .then(res => {
  923. this.$message.success("提交成功");
  924. this.form = res.data.data;
  925. this.data = res.data.data.orderItemsList;
  926. this.settlementList = res.data.data.settlementList;
  927. this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
  928. this.$emit("goBack");
  929. })
  930. .finally(() => {
  931. this.loadingBtn = false;
  932. });
  933. } else {
  934. return false;
  935. }
  936. });
  937. },
  938. revokeOrder() {
  939. this.$confirm('此操作将会撤销单子, 是否继续?', '提示', {
  940. confirmButtonText: '确定',
  941. cancelButtonText: '取消',
  942. type: 'warning'
  943. }).then(() => {
  944. this.loadingBtn = true;
  945. revoke({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList })
  946. .then(res => {
  947. this.$message.success("撤销成功");
  948. this.form = res.data.data;
  949. this.data = res.data.data.orderItemsList;
  950. this.settlementList = res.data.data.settlementList
  951. this.openEdit()
  952. })
  953. .finally(() => {
  954. this.loadingBtn = false;
  955. });
  956. }).catch(() => {
  957. });
  958. },
  959. async saveColumn() {
  960. const inSave = await this.saveColumnData(
  961. this.getColumnName(212),
  962. this.optionList
  963. );
  964. if (inSave) {
  965. this.$nextTick(() => {
  966. this.$refs.crud.doLayout();
  967. });
  968. this.$message.success("保存成功");
  969. //关闭窗口
  970. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  971. }
  972. },
  973. async resetColumn() {
  974. this.optionList = optionList;
  975. const inSave = await this.delColumnData(
  976. this.getColumnName(212),
  977. optionList
  978. );
  979. if (inSave) {
  980. this.$nextTick(() => {
  981. this.$refs.crud.doLayout();
  982. });
  983. this.getAllWorkDicts()
  984. this.$message.success("重置成功");
  985. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  986. }
  987. },
  988. openEdit() {
  989. this.detailData.status = 2
  990. this.option = this.$options.data().option;
  991. this.option2 = this.$options.data().option2;
  992. this.$refs.crud.refreshTable();
  993. this.$refs.feeInfo.refreshTable();
  994. },
  995. //返回列表
  996. backToList() {
  997. this.$emit("goBack");
  998. }
  999. },
  1000. };
  1001. </script>
  1002. <style lang="scss" scoped>
  1003. .trading-form ::v-deep .el-form-item {
  1004. margin-bottom: 8px !important;
  1005. }
  1006. ::v-deep .el-dialog__body {
  1007. padding: 0px 20px 15px 20px;
  1008. }
  1009. ::v-deep .el-form-item__error {
  1010. display: none !important;
  1011. }
  1012. .img-form ::v-deep .el-form-item {
  1013. height: 150px;
  1014. line-height: 150px;
  1015. margin-bottom: 8px !important;
  1016. }
  1017. .img-form ::v-deep .avue-upload__icon {
  1018. font-size: 20px;
  1019. width: 150px;
  1020. height: 150px;
  1021. line-height: 150px;
  1022. }
  1023. ::v-deep .el-table .cell {
  1024. padding: 0 2px !important;
  1025. }
  1026. ::v-deep .avue-crud .el-table .el-form-item__label {
  1027. left: -1px;
  1028. }
  1029. .addressTabs {
  1030. display: flex;
  1031. justify-content: center;
  1032. span {
  1033. width: 100px;
  1034. font-size: 18px;
  1035. font-weight: 600;
  1036. text-align: center;
  1037. }
  1038. }
  1039. </style>