salesOrderDetails.vue 27 KB

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