salesOrderDetails.vue 24 KB

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