detailsPage.vue 42 KB

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