salesOrderDetails.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <template>
  2. <view style="padding-top: 1rpx;">
  3. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="form" ref="form" labelWidth="150rpx"
  4. style="margin-top: 10rpx;padding-bottom: 130rpx;">
  5. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  6. <u-cell-group :border="false">
  7. <u-cell :border="false" center title="基础信息" arrow-direction="down">
  8. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  9. </u-cell>
  10. </u-cell-group>
  11. <view style="padding: 0 10rpx;">
  12. <u-form-item label="客户名称" prop="cname" borderBottom @click="selectCustomer">
  13. <u-input v-model="form.corpsName" inputAlign="right" border="none" placeholder="请选择" disabled
  14. disabledColor="#ffffff" />
  15. </u-form-item>
  16. <u-form-item label="送货地址" prop="cname" borderBottom>
  17. <u-input v-model="form.arrivalAddress" inputAlign="right" border="none" placeholder="请选择"
  18. :disabled="form.confirmStatus == 1" disabledColor="#ffffff">
  19. <template slot="suffix">
  20. <u-icon name="map" color="#fd4b09" @tap="getMap"></u-icon>
  21. </template>
  22. </u-input>
  23. </u-form-item>
  24. <u-form-item label="销售日期" prop="cname" borderBottom
  25. @click="filterAll(['businesDate','businesDate'])">
  26. <u-input v-model="form.businesDate" inputAlign="right" border="none" placeholder="请选择" disabled
  27. disabledColor="#ffffff" />
  28. </u-form-item>
  29. <u-form-item label="送货日期" prop="cname" borderBottom
  30. @click="filterAll(['requiredDeliveryDate','requiredDeliveryDate'])">
  31. <u-input v-model="form.requiredDeliveryDate" inputAlign="right" border="none" placeholder="请选择"
  32. disabled disabledColor="#ffffff" />
  33. </u-form-item>
  34. <u-form-item label="计划收款日期" labelWidth="190rpx" prop="cname" borderBottom
  35. @click="filterAll(['advanceCollectionDate','advanceCollectionDate'])">
  36. <u-input v-model="form.advanceCollectionDate" inputAlign="right" border="none" placeholder="请选择"
  37. disabled disabledColor="#ffffff" />
  38. </u-form-item>
  39. <u-form-item label="销售单号" prop="cname" borderBottom>
  40. <u-input v-model="form.sysNo" border="none" inputAlign="right" placeholder="请输入" disabled
  41. disabledColor="#ffffff" />
  42. </u-form-item>
  43. </view>
  44. </view>
  45. <view
  46. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  47. <u-cell-group :border="false">
  48. <u-cell :border="false" center @click="selectProduct">
  49. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  50. <view slot="title">
  51. <view style="display: flex;">
  52. <view>产品列表({{form.orderItemsList.length}})</view>
  53. <u-icon v-if="form.confirmStatus == 0" name="plus-circle" color="#fd4b09" size="18"
  54. style="margin-left: 20rpx;"></u-icon>
  55. </view>
  56. </view>
  57. <view slot="value">
  58. <view style="font-size: 14rpx;">总金额¥<view
  59. style="display: initial;font-size: 28rpx;font-weight: bold">{{amountNumber.amount}}
  60. </view>
  61. </view>
  62. </view>
  63. <u-icon slot="right-icon" name="arrow-right"></u-icon>
  64. </u-cell>
  65. </u-cell-group>
  66. <view style="padding: 0 10rpx;">
  67. <view
  68. style="display: flex;font-size: 12rpx;text-align: center;padding: 10rpx 0;border-top: 1rpx solid #ccc;">
  69. <view>
  70. <view>销售总数量</view>
  71. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.saleAll}}</view>
  72. </view>
  73. <view style="margin: 0 50rpx;">|</view>
  74. <view>
  75. <view>送货总数量</view>
  76. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.deliveryAll}}</view>
  77. </view>
  78. <view style="margin: 0 50rpx;">|</view>
  79. <view>
  80. <view>总数</view>
  81. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.saleAll}}</view>
  82. </view>
  83. </view>
  84. <view
  85. style="display: flex;font-size: 12rpx;text-align: center;padding: 10rpx 0;border-top: 1rpx solid #ccc;border-bottom: 1rpx solid #ccc;">
  86. <view>
  87. <view>成本</view>
  88. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.cost}}</view>
  89. </view>
  90. <view style="margin: 0 50rpx;">|</view>
  91. <view>
  92. <view>毛利</view>
  93. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.grossProfit}}</view>
  94. </view>
  95. <view style="margin: 0 50rpx;">|</view>
  96. <view>
  97. <view>送货</view>
  98. <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.delivery}}</view>
  99. </view>
  100. </view>
  101. <u-cell v-for="(item,index) in form.orderItemsList" :key="index">
  102. <view slot="label">
  103. <!-- customStyle="margin-bottom: 10px" -->
  104. <u-row>
  105. <u-col span="2.9">
  106. <u--image :showLoading="true"
  107. :src="item.url?item.url:'../../../static/images/404.png'" width="80px"
  108. height="80px" radius="10">
  109. </u--image>
  110. </u-col>
  111. <u-col span="9.1">
  112. <view
  113. style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  114. {{item.cname}}
  115. </view>
  116. <view style="display: flex;justify-content: space-between;">
  117. <view style="color: #707070;">单价:¥{{item.price}}</view>
  118. <view style="color: #707070;">数量:{{item.storageInQuantity}}</view>
  119. </view>
  120. <view style="display: flex;justify-content: space-between;">
  121. <view style="color: #707070;">金额:¥{{item.amount}}</view>
  122. <view v-if="form.confirmStatus == 0" style="color: #707070; color: red;"
  123. @click="deleteProduct(index)">
  124. <u-button type="error" size="mini" text="删除"></u-button>
  125. </view>
  126. </view>
  127. </u-col>
  128. </u-row>
  129. </view>
  130. </u-cell>
  131. </view>
  132. </view>
  133. <view
  134. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  135. <u-cell-group :border="false">
  136. <u-cell :border="false" center title="费用信息" arrow-direction="down">
  137. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  138. </u-cell>
  139. </u-cell-group>
  140. <view style="padding: 0 10rpx;">
  141. <!-- <u-form-item label="订单金额" prop="mailbox" borderBottom>
  142. <u-input v-model="form.purchaseAmount" inputAlign="right" border="none" placeholder="请输入"
  143. disabled disabledColor="#ffffff" />
  144. </u-form-item> -->
  145. <!-- <u-form-item label="优惠金额" prop="mailbox" borderBottom>
  146. <u-input v-model="form.thisUsedProfit" inputAlign="right" border="none" placeholder="请输入"
  147. :disabled="form.confirmStatus == 1" disabledColor="#ffffff" @change="calculationContract" />
  148. </u-form-item> -->
  149. <u-form-item label="应收金额" prop="mailbox" borderBottom>
  150. <u-input v-model="form.orderAmount" inputAlign="right" border="none" placeholder="请输入" disabled
  151. disabledColor="#ffffff" />
  152. </u-form-item>
  153. <view v-if="form.confirmStatus == 1">
  154. <u-form-item label="已收金额" @click="filterAll(['settlmentAmount','settlmentAmount'])" prop="mailbox"
  155. borderBottom>
  156. <u-input v-model="form.settlmentAmount" inputAlign="right" border="none" placeholder="请输入"
  157. disabled disabledColor="#ffffff" />
  158. </u-form-item>
  159. <u-form-item label="本次收款" prop="mailbox" borderBottom>
  160. <u-input type="number" clearable v-model="form.currentAmount" inputAlign="right" border="none" placeholder="请输入"
  161. :disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0" disabledColor="#ffffff" />
  162. </u-form-item>
  163. <u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
  164. <u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
  165. disabledColor="#ffffff">
  166. <template slot="suffix" style="text-align: center;">
  167. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  168. </template>
  169. </u-input>
  170. </u-form-item>
  171. <u-form-item label="收款单号" prop="mailbox" borderBottom>
  172. <u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
  173. disabledColor="#ffffff" />
  174. </u-form-item>
  175. </view>
  176. </view>
  177. </view>
  178. <view
  179. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  180. <u-cell-group :border="false">
  181. <u-cell :border="false" center title="图片信息" arrow-direction="down">
  182. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  183. </u-cell>
  184. </u-cell-group>
  185. <view style="padding: 0 10rpx;">
  186. <u-upload :disabled="form.confirmStatus == 1" :fileList="fileList1" @afterRead="afterRead"
  187. @delete="deletePic" name="1" multiple :maxCount="10"></u-upload>
  188. </view>
  189. </view>
  190. </u--form>
  191. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  192. <view style="width: 100%;display: flex;font-size: 24rpx;">
  193. <view
  194. style="width: 20%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;"
  195. @click="deleteDoc">
  196. <u-icon name="trash"></u-icon>
  197. <view>删除</view>
  198. </view>
  199. <view @click="copyDocument" style="width: 20%;display: grid;justify-items: center;">
  200. <u-icon name="file-text"></u-icon>
  201. <view>复制新增</view>
  202. </view>
  203. <view @click="conserve" v-if="form.confirmStatus == 0"
  204. style="width: 30%;background-color: #5ac725;display: grid;justify-items: center;">
  205. <u-icon name="edit-pen" color="#fff"></u-icon>
  206. <view style="color: #fff;">保存</view>
  207. </view>
  208. <view v-if="form.confirmStatus == 0" @click="submit(0)"
  209. style="width: 30%;background-color: #fd4b09;display: grid;justify-items: center;">
  210. <u-icon name="checkmark" color="#fff"></u-icon>
  211. <view style="color: #fff;">提交</view>
  212. </view>
  213. <view v-if="form.confirmStatus == 1" @click="submit(1)"
  214. style="width: 20%;background-color: #fd4b09;display: grid;justify-items: center;">
  215. <u-icon name="close" color="#fff"></u-icon>
  216. <view style="color: #fff;">撤销提交</view>
  217. </view>
  218. <view v-if="form.confirmStatus == 1" style="width: 40%;">
  219. <view @click="confirmReceipt" v-if="(form.orderAmount - form.settlmentAmount) > 0"
  220. style="background-color: #5ac725;display: grid;justify-items: center;height: 100%;">
  221. <u-icon name="checkmark" color="#fff"></u-icon>
  222. <view style="color: #fff;">确认收款</view>
  223. </view>
  224. <view v-else
  225. style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
  226. <u-icon name="checkmark" color="#fff"></u-icon>
  227. <view style="color: #fff;">已全部收款</view>
  228. </view>
  229. </view>
  230. </view>
  231. </view>
  232. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  233. @confirm="confirmTiem"></u-datetime-picker>
  234. <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
  235. @confirm="showPicker"></u-picker>
  236. </view>
  237. </template>
  238. <script>
  239. import {
  240. typeSave,
  241. removeFile,
  242. submitApp,
  243. remind,
  244. confirm,
  245. revoke,
  246. removeItem,
  247. removeId,
  248. copyOrder,
  249. collectPayment
  250. } from '@/api/views/sale/salesOrderDetails.js'
  251. import http from '@/http/api.js'
  252. import {
  253. clientId,
  254. clientSecret
  255. } from '@/common/setting'
  256. import {
  257. dateFormat
  258. } from '@/common/dateFormat'
  259. export default {
  260. data() {
  261. return {
  262. form: {
  263. orderItemsList: []
  264. },
  265. datetime: Number(new Date()),
  266. timeOpen: false,
  267. fileList1: [],
  268. screen: [],
  269. showOpen: false,
  270. columns: [],
  271. amountNumber: {
  272. deliveryAll: 0,
  273. cost: 0,
  274. grossProfit: 0,
  275. delivery: 0,
  276. saleAll: 0,
  277. amount: 0
  278. }
  279. }
  280. },
  281. onLoad(data) {
  282. this.refresh(data.id)
  283. },
  284. methods: {
  285. newCompany() {
  286. uni.$u.route('/pages/views/product/createCompany',{
  287. code:"account",
  288. title:"收款账户"
  289. });
  290. },
  291. calculationContract() {
  292. let data = {
  293. purchaseAmount: this.form.purchaseAmount ? Number(this.form.purchaseAmount) : 0,
  294. thisUsedProfit: this.form.thisUsedProfit ? Number(this.form.thisUsedProfit) : 0
  295. }
  296. this.form.orderAmount = data.purchaseAmount - data.thisUsedProfit
  297. },
  298. getMap() {
  299. let this_ = this
  300. uni.chooseLocation({
  301. success: function(res) {
  302. this_.$set(this_.form, "arrivalAddress", res.address)
  303. }
  304. });
  305. },
  306. copyDocument() {
  307. let form = {
  308. ...this.form,
  309. orderFilesList: this.fileList1
  310. }
  311. if (form.orderFilesList.length > 0) {
  312. form.orderFilesList.forEach(item => delete item.status)
  313. }
  314. let this_ = this
  315. uni.showModal({
  316. title: '提示',
  317. content: "是否确认复制新增",
  318. success: function(rest) {
  319. if (rest.confirm == true) {
  320. uni.showLoading({
  321. title: '加载中',
  322. mask: true
  323. });
  324. copyOrder(form).then(res => {
  325. uni.hideLoading();
  326. uni.showToast({
  327. icon: "none",
  328. title: '复制新增成功',
  329. mask: true
  330. });
  331. this_.form = res.data
  332. this_.fileList1 = res.data.orderFilesList
  333. this_.amountNumber = {
  334. deliveryAll: 0, //送货总数量
  335. cost: 0, //成本
  336. grossProfit: 0, //毛利
  337. delivery: 0, //送货
  338. saleAll: 0, //销售数量
  339. amount: 0
  340. }
  341. for (let item of this_.form.orderItemsList) {
  342. this_.amountNumber.saleAll += Number(item.storageInQuantity)
  343. this_.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  344. this_.amountNumber.delivery += Number(item.actualQuantity)
  345. this_.amountNumber.deliveryAll += Number(item.actualQuantity)
  346. this_.amountNumber.amount += Number(item.amount)
  347. this_.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item.storageInQuantity) * Number(item.purchasePrice) : 0)
  348. }
  349. this.form.purchaseAmount = this.amountNumber.amount
  350. })
  351. }
  352. }
  353. })
  354. },
  355. deleteDoc() {
  356. if (this.form.id) {
  357. let this_ = this
  358. uni.showModal({
  359. title: '提示',
  360. content: "是否确认删除",
  361. success: function(rest) {
  362. if (rest.confirm == true) {
  363. removeId({
  364. id: this_.form.id
  365. }).then(res => {
  366. uni.showToast({
  367. icon: "none",
  368. title: '删除成功',
  369. mask: true
  370. });
  371. setTimeout(function() {
  372. uni.navigateBack()
  373. }, 1000);
  374. })
  375. }
  376. }
  377. })
  378. } else {
  379. uni.showToast({
  380. icon: "none",
  381. title: '未保存',
  382. mask: true
  383. });
  384. }
  385. },
  386. deleteProduct(index) {
  387. let this_ = this
  388. if (this_.form.orderItemsList[index].id) {
  389. uni.showModal({
  390. title: '提示',
  391. content: "是否确认删除",
  392. success: function(rest) {
  393. if (rest.confirm == true) {
  394. uni.showLoading({
  395. title: '加载中',
  396. mask: true
  397. });
  398. removeItem({
  399. itemId: this_.form.orderItemsList[index].id
  400. }).then(res => {
  401. uni.hideLoading();
  402. uni.showToast({
  403. icon: "none",
  404. title: '删除成功',
  405. mask: true
  406. });
  407. this_.form.orderItemsList.splice(index, 1)
  408. }).catch(err => {
  409. uni.hideLoading();
  410. })
  411. }
  412. }
  413. })
  414. } else {
  415. this_.form.orderItemsList.splice(index, 1)
  416. }
  417. },
  418. //时间确认选择
  419. confirmTiem(e) {
  420. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  421. this.timeOpen = false
  422. },
  423. // 下拉选择
  424. showPicker(e) {
  425. this.form[this.screen[1]] = e.value[0].dictValue
  426. this.showOpen = false
  427. },
  428. //集合筛选条件
  429. filterAll(screen) {
  430. if (screen[1] == "account") {
  431. if (this.form.confirmStatus == 0) {
  432. return uni.showToast({
  433. icon: "none",
  434. title: '禁止操作',
  435. mask: true
  436. });
  437. }else if((this.form.orderAmount - this.form.settlmentAmount) == 0){
  438. return uni.showToast({
  439. icon: "none",
  440. title: '禁止操作',
  441. mask: true
  442. });
  443. }
  444. } else {
  445. if(screen[1] !== "settlmentAmount"){
  446. if (this.form.confirmStatus == 1) {
  447. return uni.showToast({
  448. icon: "none",
  449. title: '禁止操作',
  450. mask: true
  451. });
  452. }
  453. }
  454. }
  455. this.screen = screen
  456. switch (screen[1]) {
  457. case "businesDate":
  458. this.timeOpen = true
  459. break;
  460. case "requiredDeliveryDate":
  461. this.timeOpen = true
  462. break;
  463. case "advanceCollectionDate":
  464. this.timeOpen = true
  465. break;
  466. case "account":
  467. this.$u.api.getWorkDicts('account').then(res => {
  468. this.columns = [res.data]
  469. this.showOpen = true
  470. })
  471. break;
  472. case "settlmentAmount":
  473. uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
  474. break;
  475. }
  476. },
  477. refresh(id) {
  478. uni.showLoading({
  479. title: '加载中',
  480. mask: true
  481. });
  482. typeSave({
  483. id: id
  484. }).then(res => {
  485. this.form = res.data
  486. this.fileList1 = res.data.orderFilesList
  487. this.amountNumber = {
  488. deliveryAll: 0, //送货总数量
  489. cost: 0, //成本
  490. grossProfit: 0, //毛利
  491. delivery: 0, //送货
  492. saleAll: 0, //销售数量
  493. amount: 0
  494. }
  495. for (let item of this.form.orderItemsList) {
  496. this.amountNumber.saleAll += Number(item.storageInQuantity)
  497. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  498. this.amountNumber.delivery += Number(item.actualQuantity)
  499. this.amountNumber.deliveryAll += Number(item.actualQuantity)
  500. this.amountNumber.amount += Number(item.amount)
  501. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item.storageInQuantity) * Number(item.purchasePrice) : 0)
  502. }
  503. this.form.purchaseAmount = this.amountNumber.amount
  504. setTimeout(function() {
  505. uni.hideLoading();
  506. }, 500);
  507. })
  508. },
  509. //确认收款
  510. confirmReceipt() {
  511. let this_ = this
  512. let form = {
  513. ...this_.form,
  514. orderFilesList: this_.fileList1
  515. }
  516. if (form.orderFilesList.length > 0) {
  517. form.orderFilesList.forEach(item => delete item.status)
  518. }
  519. if(!form.currentAmount){
  520. return uni.showToast({
  521. icon: "none",
  522. title: '本次收款金额不能为空',
  523. mask: true,
  524. duration:2000
  525. });
  526. }
  527. if(!form.account){
  528. return uni.showToast({
  529. icon: "none",
  530. title: '未选择收款账户',
  531. mask: true,
  532. duration:2000
  533. });
  534. }
  535. uni.showModal({
  536. title: '是否确认收款',
  537. content: '本次收款金额'+form.currentAmount,
  538. success: function(rest) {
  539. if (rest.confirm == true) {
  540. uni.showLoading({
  541. title: '加载中',
  542. mask: true
  543. });
  544. collectPayment(form).then(res=>{
  545. uni.showToast({
  546. icon: "none",
  547. title: '收款成功',
  548. mask: true,
  549. duration:2000
  550. });
  551. setTimeout(function() {
  552. uni.hideLoading();
  553. this_.refresh(res.data.id)
  554. }, 1000);
  555. })
  556. }
  557. }
  558. })
  559. },
  560. //保存
  561. conserve() {
  562. let form = {
  563. ...this.form,
  564. orderFilesList: this.fileList1
  565. }
  566. if (form.orderFilesList.length > 0) {
  567. form.orderFilesList.forEach(item => delete item.status)
  568. }
  569. uni.showLoading({
  570. title: '加载中',
  571. mask: true
  572. });
  573. submitApp(form).then(res => {
  574. uni.showToast({
  575. icon: "none",
  576. title: '保存成功',
  577. mask: true
  578. });
  579. let _this = this
  580. setTimeout(function() {
  581. uni.hideLoading();
  582. _this.refresh(res.data.id)
  583. }, 1000);
  584. })
  585. },
  586. //提交
  587. submit(type) {
  588. let form = {
  589. ...this.form,
  590. orderFilesList: this.fileList1
  591. }
  592. let this_ = this
  593. uni.showLoading({
  594. title: '提交中',
  595. mask: true
  596. });
  597. if (type == 0) {
  598. remind(form).then(res => {
  599. uni.hideLoading();
  600. if (res.data) {
  601. uni.showModal({
  602. title: '提示',
  603. content: res.data,
  604. success: function(rest) {
  605. if (rest.confirm == true) {
  606. uni.showLoading({
  607. title: '提交中',
  608. mask: true
  609. });
  610. confirm(form).then(resth => {
  611. uni.showToast({
  612. icon: "none",
  613. title: '提交成功',
  614. mask: true
  615. });
  616. setTimeout(function() {
  617. // uni.hideLoading();
  618. this_.refresh(resth.data.id)
  619. }, 1000);
  620. })
  621. }
  622. }
  623. })
  624. } else {
  625. uni.showLoading({
  626. title: '提交中',
  627. mask: true
  628. });
  629. confirm(form).then(rest => {
  630. uni.showToast({
  631. icon: "none",
  632. title: '提交成功',
  633. mask: true
  634. });
  635. setTimeout(function() {
  636. uni.hideLoading();
  637. this_.refresh(rest.data.id)
  638. }, 1000);
  639. })
  640. }
  641. })
  642. } else if (type == 1) {
  643. revoke(form).then(res => {
  644. uni.showToast({
  645. icon: "none",
  646. title: '撤销成功',
  647. mask: true
  648. });
  649. setTimeout(function() {
  650. uni.hideLoading();
  651. this_.refresh(res.data.id)
  652. }, 1000);
  653. })
  654. }
  655. },
  656. //客户选择返回触发
  657. otherFun(customer) {
  658. this.form.corpsName = customer.cname
  659. this.form.corpId = customer.id
  660. },
  661. selectProduct() {
  662. if (this.form.confirmStatus == 0) {
  663. this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
  664. }
  665. },
  666. //商品选择返回
  667. getProduct(dataList) {
  668. for (let item of dataList) {
  669. this.form.orderItemsList.push({
  670. ...item
  671. })
  672. }
  673. this.amountNumber = {
  674. deliveryAll: 0, //送货总数量
  675. cost: 0, //成本
  676. grossProfit: 0, //毛利
  677. delivery: 0, //送货
  678. saleAll: 0, //销售数量
  679. amount: 0
  680. }
  681. for (let item of this.form.orderItemsList) {
  682. this.amountNumber.saleAll += Number(item.storageInQuantity)
  683. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  684. this.amountNumber.delivery += Number(item.actualQuantity)
  685. this.amountNumber.deliveryAll += item.actualQuantity ? Number(item.actualQuantity) : 0
  686. this.amountNumber.amount += Number(item.amount)
  687. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  688. .storageInQuantity) * Number(item.purchasePrice) : 0)
  689. }
  690. this.form.purchaseAmount = this.amountNumber.amount
  691. },
  692. selectCustomer() {
  693. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  694. corpType: 'KH'
  695. });
  696. },
  697. // 新增图片
  698. async afterRead(event) {
  699. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  700. let lists = [].concat(event.file)
  701. let fileListLen = this[`fileList${event.name}`].length
  702. lists.map((item) => {
  703. this[`fileList${event.name}`].push({
  704. ...item,
  705. status: 'uploading',
  706. message: '上传中'
  707. })
  708. })
  709. for (let i = 0; i < lists.length; i++) {
  710. const result = await this.uploadFilePromise(lists[i].url)
  711. let item = this[`fileList${event.name}`][fileListLen]
  712. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  713. status: 'success',
  714. sort: this.fileList1.length,
  715. fileName: JSON.parse(result).data.originalName,
  716. url: JSON.parse(result).data.link
  717. }))
  718. fileListLen++
  719. }
  720. },
  721. uploadFilePromise(url) {
  722. return new Promise((resolve, reject) => {
  723. let a = uni.uploadFile({
  724. url: http.config.baseURL +
  725. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  726. filePath: url,
  727. name: 'file',
  728. formData: {
  729. user: 'test'
  730. },
  731. header: {
  732. // 客户端认证参数
  733. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  734. clientSecret),
  735. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  736. },
  737. success: (res) => {
  738. setTimeout(() => {
  739. resolve(res.data)
  740. }, 1000)
  741. }
  742. });
  743. })
  744. },
  745. // 删除图片
  746. deletePic(event) {
  747. let this_ = this
  748. uni.showModal({
  749. title: '提示',
  750. content: '是否确认删除',
  751. success: function(rest) {
  752. if (rest.confirm == true) {
  753. if (this_[`fileList${event.name}`][event.index].id) {
  754. removeFile({
  755. ids: this_[`fileList${event.name}`][event.index].id
  756. }).then(res => {
  757. this_[`fileList${event.name}`].splice(event.index, 1)
  758. })
  759. } else {
  760. this_[`fileList${event.name}`].splice(event.index, 1)
  761. }
  762. }
  763. }
  764. })
  765. },
  766. }
  767. }
  768. </script>
  769. <style lang="scss" scoped>
  770. ::v-deep .u-cell__body {
  771. padding: 20rpx 10rpx;
  772. }
  773. </style>