salesOrderDetails.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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?amountNumber.cost.toFixed(2):'0.00'}}</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?amountNumber.grossProfit.toFixed(2):'0.00'}}</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?parseInt(item.storageInQuantity):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.purchaseAmount" inputAlign="right" border="none" placeholder="请输入" disabled
  151. disabledColor="#ffffff" />
  152. </u-form-item>
  153. <u-form-item label="优惠金额" prop="mailbox" borderBottom>
  154. <u-input v-model="form.thisUsedProfit" inputAlign="right" border="none" placeholder="请输入"
  155. :disabled="false" disabledColor="#ffffff" @change="calculationContract"/>
  156. </u-form-item>
  157. <u-form-item label="应收金额" prop="mailbox" borderBottom>
  158. <u-input v-model="form.orderAmount" inputAlign="right" border="none" placeholder="请输入" disabled
  159. disabledColor="#ffffff" />
  160. </u-form-item>
  161. <view v-if="form.confirmStatus == 1">
  162. <u-form-item label="已收金额" @click="filterAll(['settlmentAmount','settlmentAmount'])"
  163. prop="mailbox" borderBottom>
  164. <u-input v-model="form.settlmentAmount" inputAlign="right" border="none" placeholder="请输入"
  165. disabled disabledColor="#ffffff" />
  166. </u-form-item>
  167. <u-form-item label="本次收款" prop="mailbox" borderBottom>
  168. <u-input type="number" clearable v-model="form.currentAmount" inputAlign="right"
  169. border="none" placeholder="请输入"
  170. :disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0"
  171. disabledColor="#ffffff" />
  172. </u-form-item>
  173. <u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
  174. <u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
  175. disabledColor="#ffffff">
  176. <template slot="suffix" style="text-align: center;">
  177. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  178. </template>
  179. </u-input>
  180. </u-form-item>
  181. <u-form-item label="收款单号" prop="mailbox" borderBottom>
  182. <u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
  183. disabledColor="#ffffff" />
  184. </u-form-item>
  185. </view>
  186. </view>
  187. </view>
  188. <view
  189. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  190. <u-cell-group :border="false">
  191. <u-cell :border="false" center title="图片信息" arrow-direction="down">
  192. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  193. <view slot="value">
  194. <view v-if="form.confirmStatus == 1" @click.stop="saveAttachment"
  195. style="padding: 2rpx 20rpx;border:1rpx solid #FD4B09;border-radius: 100rpx;color: #FD4B09;">
  196. 保存
  197. </view>
  198. </view>
  199. </u-cell>
  200. </u-cell-group>
  201. <view style="padding: 0 10rpx;">
  202. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  203. :maxCount="10"></u-upload>
  204. </view>
  205. </view>
  206. </u--form>
  207. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  208. <view style="width: 100%;display: flex;font-size: 24rpx;">
  209. <view
  210. style="width: 20%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;"
  211. @click="deleteDoc">
  212. <u-icon name="trash"></u-icon>
  213. <view>删除</view>
  214. </view>
  215. <view @click="copyDocument" style="width: 20%;display: grid;justify-items: center;">
  216. <u-icon name="file-text"></u-icon>
  217. <view>复制新增</view>
  218. </view>
  219. <view @click="conserve" v-if="form.confirmStatus == 0"
  220. style="width: 30%;background-color: #5ac725;display: grid;justify-items: center;">
  221. <u-icon name="edit-pen" color="#fff"></u-icon>
  222. <view style="color: #fff;">保存</view>
  223. </view>
  224. <view v-if="form.confirmStatus == 0" @click="submit(0)"
  225. style="width: 30%;background-color: #fd4b09;display: grid;justify-items: center;">
  226. <u-icon name="checkmark" color="#fff"></u-icon>
  227. <view style="color: #fff;">提交</view>
  228. </view>
  229. <view v-if="form.confirmStatus == 1" @click="submit(1)"
  230. style="width: 20%;background-color: #fd4b09;display: grid;justify-items: center;">
  231. <u-icon name="close" color="#fff"></u-icon>
  232. <view style="color: #fff;">撤销提交</view>
  233. </view>
  234. <view v-if="form.confirmStatus == 1" style="width: 40%;">
  235. <view @click="confirmReceipt" v-if="(form.orderAmount - form.settlmentAmount) > 0"
  236. style="background-color: #5ac725;display: grid;justify-items: center;height: 100%;">
  237. <u-icon name="checkmark" color="#fff"></u-icon>
  238. <view style="color: #fff;">确认收款</view>
  239. </view>
  240. <view v-else style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
  241. <u-icon name="checkmark" color="#fff"></u-icon>
  242. <view style="color: #fff;">已全部收款</view>
  243. </view>
  244. </view>
  245. </view>
  246. </view>
  247. <view v-if="choice" class="mask" @touchmove.stop.prevent="moveHandle" @click="choice = !choice">
  248. <view class="choice">
  249. <view style="display: flex;;justify-content: right;margin-right: 5rpx;">
  250. <view
  251. style="width: 40rpx;height: 40rpx;background-color: #fff;border-radius: 10rpx;transform: rotate(45deg);margin-top: -8rpx;z-index: -1;">
  252. </view>
  253. </view>
  254. <view style="margin-top: -25rpx;z-index: 99;background-color: #fff;">
  255. <u-cell-group :border="false">
  256. <u-cell icon="edit-pen" :title="connected?'打印':'未连接'" @click.native.stop="connectingDevices"></u-cell>
  257. <u-cell icon="photo" title="保存图片" :border="false" @click.native.stop="generatePictures">
  258. </u-cell>
  259. </u-cell-group>
  260. </view>
  261. </view>
  262. </view>
  263. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  264. @confirm="confirmTiem"></u-datetime-picker>
  265. <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
  266. @confirm="showPicker"></u-picker>
  267. </view>
  268. </template>
  269. <script>
  270. import {
  271. typeSave,
  272. removeFile,
  273. submitApp,
  274. remind,
  275. confirm,
  276. revoke,
  277. removeItem,
  278. removeId,
  279. copyOrder,
  280. collectPayment,
  281. saveAtta
  282. } from '@/api/views/sale/salesOrderDetails.js'
  283. import http from '@/http/api.js'
  284. import {
  285. clientId,
  286. clientSecret
  287. } from '@/common/setting'
  288. import {
  289. dateFormat
  290. } from '@/common/dateFormat'
  291. // #ifdef APP-PLUS
  292. const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
  293. import printConnect from "@/common/print.js"; //引入打印机模板文件
  294. let print;
  295. // #endif
  296. import {
  297. GET_REQUEST_DATA
  298. } from "@/store/gettersType.js";
  299. import {
  300. mapGetters,
  301. mapActions
  302. } from 'vuex';
  303. import {
  304. DX
  305. } from '@/common/dateFormat.js';
  306. export default {
  307. data() {
  308. return {
  309. form: {
  310. orderItemsList: []
  311. },
  312. datetime: Number(new Date()),
  313. timeOpen: false,
  314. fileList1: [],
  315. screen: [],
  316. showOpen: false,
  317. choice: false,
  318. columns: [],
  319. connected:false,
  320. amountNumber: {
  321. deliveryAll: 0,
  322. cost: 0,
  323. grossProfit: 0,
  324. delivery: 0,
  325. saleAll: 0,
  326. amount: 0
  327. }
  328. }
  329. },
  330. onLoad(data) {
  331. this.refresh(data.id)
  332. },
  333. computed: {
  334. ...mapGetters([GET_REQUEST_DATA])
  335. },
  336. onShow() {
  337. this.choice = false
  338. let this_ = this
  339. // #ifdef APP-PLUS
  340. HanyinPlugin.IsOpened(res => {
  341. this_.connected = res.state
  342. if(this_.GET_REQUEST_DATA.length == 0){
  343. this_.connected = false
  344. print = new printConnect({},1); //打印机连接
  345. }
  346. });
  347. // #endif
  348. },
  349. onNavigationBarButtonTap(e) {
  350. this.choice = !this.choice
  351. },
  352. methods: {
  353. //跳转连接设备
  354. connectingDevices() {
  355. if(this.connected){
  356. this.senBleLabel()
  357. }else{
  358. uni.$u.route('/pages/views/bluetooth/index', {
  359. data: JSON.stringify(this.form)
  360. });
  361. }
  362. },
  363. senBleLabel() {
  364. // if (!print) return;
  365. console.log(this.$Mock.printTemplate.pagConfig)
  366. this.$Mock.printTemplate.pagConfig = 0
  367. let data = []
  368. let i = 0
  369. for (let item of this.form.orderItemsList) {
  370. data.push({
  371. "top": Number(i * 40 + 90),
  372. "left": "0",
  373. "textAlign": "start",
  374. "width": "270",
  375. "fontSize": 9,
  376. "text": item.cname,
  377. "type": "text",
  378. "fontWeight": "400",
  379. "height": "20"
  380. })
  381. data.push({
  382. "top": Number(i * 40 + 110),
  383. "left": "140",
  384. "textAlign": "start",
  385. "width": "40",
  386. "fontSize": 8,
  387. "text": Number(item.storageInQuantity),
  388. "type": "text",
  389. "fontWeight": "400",
  390. "height": "20"
  391. })
  392. data.push({
  393. "top": Number(i * 40 + 110),
  394. "left": "160",
  395. "textAlign": "start",
  396. "width": "50",
  397. "fontSize": 8,
  398. "text": item.price,
  399. "type": "text",
  400. "fontWeight": "400",
  401. "height": "20"
  402. })
  403. data.push({
  404. "top": Number(i * 40 + 110),
  405. "left": "210",
  406. "textAlign": "start",
  407. "width": "60",
  408. "fontSize": 8,
  409. "text": item.amount,
  410. "type": "text",
  411. "fontWeight": "400",
  412. "height": "20"
  413. })
  414. i++
  415. }
  416. data.push({
  417. "top": Number(i * 40 + 90),
  418. "left": "20",
  419. "textAlign": "start",
  420. "width": "270",
  421. "fontSize": 9,
  422. "text": "合计:",
  423. "type": "text",
  424. "fontWeight": "400",
  425. "height": "20"
  426. })
  427. data.push({
  428. "top": Number(i * 40 + 90),
  429. "left": "140",
  430. "textAlign": "start",
  431. "width": "40",
  432. "fontSize": 8,
  433. "text": this.amountNumber.saleAll,
  434. "type": "text",
  435. "fontWeight": "400",
  436. "height": "20"
  437. })
  438. data.push({
  439. "top": Number(i * 40 + 90),
  440. "left": "210",
  441. "textAlign": "start",
  442. "width": "60",
  443. "fontSize": 8,
  444. "text": this.form.orderAmount,
  445. "type": "text",
  446. "fontWeight": "400",
  447. "height": "20"
  448. })
  449. data.push({
  450. "top": Number(i * 40 + 110),
  451. "left": "20",
  452. "textAlign": "start",
  453. "width": "270",
  454. "fontSize": 9,
  455. "text": "产品合计:",
  456. "type": "text",
  457. "fontWeight": "400",
  458. "height": "20"
  459. })
  460. data.push({
  461. "top": Number(i * 40 + 110),
  462. "left": "70",
  463. "textAlign": "start",
  464. "width": "70",
  465. "fontSize": 8,
  466. "text": this.amountNumber.amount,
  467. "type": "text",
  468. "fontWeight": "400",
  469. "height": "20"
  470. })
  471. data.push({
  472. "top": Number(i * 40 + 110),
  473. "left": "140",
  474. "textAlign": "start",
  475. "width": "60",
  476. "fontSize": 8,
  477. "text": "合计金额:",
  478. "type": "text",
  479. "fontWeight": "400",
  480. "height": "20"
  481. })
  482. data.push({
  483. "top": Number(i * 40 + 110),
  484. "left": "190",
  485. "textAlign": "start",
  486. "width": "80",
  487. "fontSize": 8,
  488. "text": DX(this.amountNumber.amount),
  489. "type": "text",
  490. "fontWeight": "400",
  491. "height": "40"
  492. })
  493. data.push({
  494. "top": Number(i * 40 + 130),
  495. "left": "20",
  496. "textAlign": "start",
  497. "width": "270",
  498. "fontSize": 9,
  499. "text": "订货电话:" + this.form.clientAttn,
  500. "type": "text",
  501. "fontWeight": "400",
  502. "height": "20"
  503. })
  504. data.push({
  505. "top": Number(i * 40 + 150),
  506. "left": "20",
  507. "textAlign": "start",
  508. "width": "270",
  509. "fontSize": 9,
  510. "text": "制单人:" + this.form.client,
  511. "type": "text",
  512. "fontWeight": "400",
  513. "height": "20"
  514. })
  515. data.push({
  516. "top": Number(i * 40 + 150),
  517. "left": "140",
  518. "textAlign": "start",
  519. "width": "80",
  520. "fontSize": 8,
  521. "text": "收货人(签字):",
  522. "type": "text",
  523. "fontWeight": "400",
  524. "height": "20"
  525. })
  526. print.startPrint({
  527. SALES_SLIP: this.form.sysNo,
  528. CUSTOMER_NAME: this.form.corpsName,
  529. SALES_DATE: this.form.businesDate.slice(0, 10)
  530. }, {
  531. pageHeight: (this.form.orderItemsList.length * 40) / 3
  532. }, data);
  533. },
  534. generatePictures() {
  535. uni.$u.route('/pages/views/bluetooth/salesSlipTable', {
  536. data: JSON.stringify(this.form)
  537. });
  538. },
  539. //遮罩层禁止点击空方法
  540. moveHandle() {},
  541. newCompany() {
  542. uni.$u.route('/pages/views/product/createCompany', {
  543. code: "account",
  544. title: "收款账户"
  545. });
  546. },
  547. calculationContract() {
  548. let data = {
  549. purchaseAmount: this.form.purchaseAmount ? Number(this.form.purchaseAmount) : 0,
  550. thisUsedProfit: this.form.thisUsedProfit ? Number(this.form.thisUsedProfit) : 0
  551. }
  552. this.form.orderAmount = data.purchaseAmount - data.thisUsedProfit;
  553. this.form.currentAmount = this.form.orderAmount;
  554. },
  555. getMap() {
  556. let this_ = this
  557. uni.chooseLocation({
  558. success: function(res) {
  559. this_.$set(this_.form, "arrivalAddress", res.address)
  560. }
  561. });
  562. },
  563. copyDocument() {
  564. let form = {
  565. ...this.form,
  566. orderFilesList: this.fileList1
  567. }
  568. if (form.orderFilesList.length > 0) {
  569. form.orderFilesList.forEach(item => delete item.status)
  570. }
  571. let this_ = this
  572. uni.showModal({
  573. title: '提示',
  574. content: "是否确认复制新增",
  575. success: function(rest) {
  576. if (rest.confirm == true) {
  577. uni.showLoading({
  578. title: '加载中',
  579. mask: true
  580. });
  581. copyOrder(form).then(res => {
  582. uni.hideLoading();
  583. uni.showToast({
  584. icon: "none",
  585. title: '复制新增成功',
  586. mask: true
  587. });
  588. this_.form = res.data
  589. this_.fileList1 = res.data.orderFilesList
  590. this_.amountNumber = {
  591. deliveryAll: 0, //送货总数量
  592. cost: 0, //成本
  593. grossProfit: 0, //毛利
  594. delivery: 0, //送货
  595. saleAll: 0, //销售数量
  596. amount: 0
  597. }
  598. for (let item of this_.form.orderItemsList) {
  599. this_.amountNumber.saleAll += Number(item.storageInQuantity)
  600. this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
  601. item.purchasePrice)
  602. this_.amountNumber.delivery += Number(item.actualQuantity)
  603. this_.amountNumber.deliveryAll += Number(item.actualQuantity)
  604. this_.amountNumber.amount += Number(item.amount)
  605. this_.amountNumber.grossProfit += Number(item.amount) - (item
  606. .purchasePrice ? Number(item.storageInQuantity) * Number(
  607. item.purchasePrice) : 0)
  608. }
  609. this.form.purchaseAmount = this.amountNumber.amount
  610. })
  611. }
  612. }
  613. })
  614. },
  615. deleteDoc() {
  616. if (this.form.id) {
  617. let this_ = this
  618. if (this_.form.confirmStatus == 1) {
  619. return uni.showToast({
  620. icon: "none",
  621. title: '禁止删除',
  622. mask: true
  623. });
  624. }
  625. uni.showModal({
  626. title: '提示',
  627. content: "是否确认删除",
  628. success: function(rest) {
  629. if (rest.confirm == true) {
  630. removeId({
  631. id: this_.form.id
  632. }).then(res => {
  633. uni.showToast({
  634. icon: "none",
  635. title: '删除成功',
  636. mask: true
  637. });
  638. setTimeout(function() {
  639. uni.navigateBack()
  640. }, 1000);
  641. })
  642. }
  643. }
  644. })
  645. } else {
  646. uni.showToast({
  647. icon: "none",
  648. title: '未保存',
  649. mask: true
  650. });
  651. }
  652. },
  653. deleteProduct(index) {
  654. let this_ = this
  655. if (this_.form.orderItemsList[index].id) {
  656. uni.showModal({
  657. title: '提示',
  658. content: "是否确认删除",
  659. success: function(rest) {
  660. if (rest.confirm == true) {
  661. uni.showLoading({
  662. title: '加载中',
  663. mask: true
  664. });
  665. removeItem({
  666. itemId: this_.form.orderItemsList[index].id
  667. }).then(res => {
  668. uni.hideLoading();
  669. uni.showToast({
  670. icon: "none",
  671. title: '删除成功',
  672. mask: true
  673. });
  674. this_.form.orderItemsList.splice(index, 1)
  675. }).catch(err => {
  676. uni.hideLoading();
  677. })
  678. }
  679. }
  680. })
  681. } else {
  682. this_.form.orderItemsList.splice(index, 1)
  683. }
  684. },
  685. //时间确认选择
  686. confirmTiem(e) {
  687. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  688. this.timeOpen = false
  689. },
  690. // 下拉选择
  691. showPicker(e) {
  692. this.form[this.screen[1]] = e.value[0].dictValue
  693. this.showOpen = false
  694. },
  695. //集合筛选条件
  696. filterAll(screen) {
  697. if (screen[1] == "account") {
  698. if (this.form.confirmStatus == 0) {
  699. return uni.showToast({
  700. icon: "none",
  701. title: '禁止操作',
  702. mask: true
  703. });
  704. } else if ((this.form.orderAmount - this.form.settlmentAmount) == 0) {
  705. return uni.showToast({
  706. icon: "none",
  707. title: '禁止操作',
  708. mask: true
  709. });
  710. }
  711. } else {
  712. if (screen[1] !== "settlmentAmount") {
  713. if (this.form.confirmStatus == 1) {
  714. return uni.showToast({
  715. icon: "none",
  716. title: '禁止操作',
  717. mask: true
  718. });
  719. }
  720. }
  721. }
  722. this.screen = screen
  723. switch (screen[1]) {
  724. case "businesDate":
  725. this.timeOpen = true
  726. break;
  727. case "requiredDeliveryDate":
  728. this.timeOpen = true
  729. break;
  730. case "advanceCollectionDate":
  731. this.timeOpen = true
  732. break;
  733. case "account":
  734. this.$u.api.getWorkDicts('account').then(res => {
  735. this.columns = [res.data]
  736. this.showOpen = true
  737. })
  738. break;
  739. case "settlmentAmount":
  740. uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
  741. break;
  742. }
  743. },
  744. refresh(id) {
  745. uni.showLoading({
  746. title: '加载中',
  747. mask: true
  748. });
  749. typeSave({
  750. id: id
  751. }).then(res => {
  752. this.form = res.data
  753. this.fileList1 = res.data.orderFilesList
  754. this.amountNumber = {
  755. deliveryAll: 0, //送货总数量
  756. cost: 0, //成本
  757. grossProfit: 0, //毛利
  758. delivery: 0, //送货
  759. saleAll: 0, //销售数量
  760. amount: 0
  761. }
  762. for (let item of this.form.orderItemsList) {
  763. this.amountNumber.saleAll += Number(item.storageInQuantity)
  764. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  765. this.amountNumber.delivery += Number(item.actualQuantity)
  766. this.amountNumber.deliveryAll += Number(item.actualQuantity)
  767. this.amountNumber.amount += Number(item.amount)
  768. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  769. .storageInQuantity) * Number(item.purchasePrice) : 0)
  770. }
  771. this.form.purchaseAmount = this.amountNumber.amount
  772. setTimeout(function() {
  773. uni.hideLoading();
  774. }, 500);
  775. })
  776. },
  777. //确认收款
  778. confirmReceipt() {
  779. let this_ = this
  780. let form = {
  781. ...this_.form,
  782. orderFilesList: this_.fileList1
  783. }
  784. if (form.orderFilesList.length > 0) {
  785. form.orderFilesList.forEach(item => delete item.status)
  786. }
  787. if (!form.currentAmount) {
  788. return uni.showToast({
  789. icon: "none",
  790. title: '本次收款金额不能为空',
  791. mask: true,
  792. duration: 2000
  793. });
  794. }
  795. if (!form.account) {
  796. return uni.showToast({
  797. icon: "none",
  798. title: '未选择收款账户',
  799. mask: true,
  800. duration: 2000
  801. });
  802. }
  803. uni.showModal({
  804. title: '是否确认收款',
  805. content: '本次收款金额' + form.currentAmount,
  806. success: function(rest) {
  807. if (rest.confirm == true) {
  808. uni.showLoading({
  809. title: '加载中',
  810. mask: true
  811. });
  812. collectPayment(form).then(res => {
  813. uni.showToast({
  814. icon: "none",
  815. title: '收款成功',
  816. mask: true,
  817. duration: 2000
  818. });
  819. setTimeout(function() {
  820. uni.hideLoading();
  821. this_.refresh(res.data.id)
  822. }, 1000);
  823. })
  824. }
  825. }
  826. })
  827. },
  828. //保存附件
  829. saveAttachment() {
  830. let form = {
  831. pid: this.form.id,
  832. orderFilesList: this.fileList1
  833. }
  834. if (form.orderFilesList.length > 0) {
  835. form.orderFilesList.forEach(item => delete item.status)
  836. }
  837. uni.showLoading({
  838. title: '加载中',
  839. mask: true
  840. });
  841. saveAtta(form).then(res => {
  842. uni.showToast({
  843. icon: "none",
  844. title: '保存成功',
  845. mask: true
  846. });
  847. let _this = this
  848. setTimeout(function() {
  849. uni.hideLoading();
  850. _this.refresh(res.data.id)
  851. }, 1000);
  852. })
  853. },
  854. //保存
  855. conserve() {
  856. let form = {
  857. ...this.form,
  858. orderFilesList: this.fileList1
  859. }
  860. if (form.orderFilesList.length > 0) {
  861. form.orderFilesList.forEach(item => delete item.status)
  862. }
  863. uni.showLoading({
  864. title: '加载中',
  865. mask: true
  866. });
  867. submitApp(form).then(res => {
  868. uni.showToast({
  869. icon: "none",
  870. title: '保存成功',
  871. mask: true
  872. });
  873. let _this = this
  874. setTimeout(function() {
  875. uni.hideLoading();
  876. _this.refresh(res.data.id)
  877. }, 1000);
  878. })
  879. },
  880. //提交
  881. submit(type) {
  882. let form = {
  883. ...this.form,
  884. orderFilesList: this.fileList1
  885. }
  886. let this_ = this
  887. uni.showLoading({
  888. title: '提交中',
  889. mask: true
  890. });
  891. if (type == 0) {
  892. remind(form).then(res => {
  893. uni.hideLoading();
  894. if (res.data) {
  895. uni.showModal({
  896. title: '提示',
  897. content: res.data,
  898. success: function(rest) {
  899. if (rest.confirm == true) {
  900. uni.showLoading({
  901. title: '提交中',
  902. mask: true
  903. });
  904. confirm(form).then(resth => {
  905. uni.showToast({
  906. icon: "none",
  907. title: '提交成功',
  908. mask: true
  909. });
  910. setTimeout(function() {
  911. // uni.hideLoading();
  912. this_.refresh(resth.data.id)
  913. }, 1000);
  914. })
  915. }
  916. }
  917. })
  918. } else {
  919. uni.showLoading({
  920. title: '提交中',
  921. mask: true
  922. });
  923. confirm(form).then(rest => {
  924. uni.showToast({
  925. icon: "none",
  926. title: '提交成功',
  927. mask: true
  928. });
  929. setTimeout(function() {
  930. uni.hideLoading();
  931. this_.refresh(rest.data.id)
  932. }, 1000);
  933. })
  934. }
  935. })
  936. } else if (type == 1) {
  937. revoke(form).then(res => {
  938. uni.showToast({
  939. icon: "none",
  940. title: '撤销成功',
  941. mask: true
  942. });
  943. setTimeout(function() {
  944. uni.hideLoading();
  945. this_.refresh(res.data.id)
  946. }, 1000);
  947. })
  948. }
  949. },
  950. //客户选择返回触发
  951. otherFun(customer) {
  952. this.form.corpsName = customer.cname
  953. this.form.corpId = customer.id
  954. },
  955. selectProduct() {
  956. if (this.form.confirmStatus == 0) {
  957. this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
  958. }
  959. },
  960. //商品选择返回
  961. getProduct(dataList) {
  962. for (let item of dataList) {
  963. this.form.orderItemsList.push({
  964. ...item
  965. })
  966. }
  967. this.amountNumber = {
  968. deliveryAll: 0, //送货总数量
  969. cost: 0, //成本
  970. grossProfit: 0, //毛利
  971. delivery: 0, //送货
  972. saleAll: 0, //销售数量
  973. amount: 0
  974. }
  975. for (let item of this.form.orderItemsList) {
  976. this.amountNumber.saleAll += Number(item.storageInQuantity)
  977. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  978. this.amountNumber.delivery += Number(item.actualQuantity)
  979. this.amountNumber.deliveryAll += item.actualQuantity ? Number(item.actualQuantity) : 0
  980. this.amountNumber.amount += Number(item.amount)
  981. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  982. .storageInQuantity) * Number(item.purchasePrice) : 0)
  983. }
  984. this.form.purchaseAmount = this.amountNumber.amount
  985. },
  986. selectCustomer() {
  987. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  988. corpType: 'KH'
  989. });
  990. },
  991. // 新增图片
  992. async afterRead(event) {
  993. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  994. let lists = [].concat(event.file)
  995. let fileListLen = this[`fileList${event.name}`].length
  996. lists.map((item) => {
  997. this[`fileList${event.name}`].push({
  998. ...item,
  999. status: 'uploading',
  1000. message: '上传中'
  1001. })
  1002. })
  1003. for (let i = 0; i < lists.length; i++) {
  1004. const result = await this.uploadFilePromise(lists[i].url)
  1005. let item = this[`fileList${event.name}`][fileListLen]
  1006. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  1007. status: 'success',
  1008. sort: this.fileList1.length,
  1009. fileName: JSON.parse(result).data.originalName,
  1010. url: JSON.parse(result).data.link
  1011. }))
  1012. fileListLen++
  1013. }
  1014. },
  1015. uploadFilePromise(url) {
  1016. return new Promise((resolve, reject) => {
  1017. let a = uni.uploadFile({
  1018. url: http.config.baseURL +
  1019. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  1020. filePath: url,
  1021. name: 'file',
  1022. formData: {
  1023. user: 'test'
  1024. },
  1025. header: {
  1026. // 客户端认证参数
  1027. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  1028. clientSecret),
  1029. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  1030. },
  1031. success: (res) => {
  1032. setTimeout(() => {
  1033. resolve(res.data)
  1034. }, 1000)
  1035. }
  1036. });
  1037. })
  1038. },
  1039. // 删除图片
  1040. deletePic(event) {
  1041. let this_ = this
  1042. uni.showModal({
  1043. title: '提示',
  1044. content: '是否确认删除',
  1045. success: function(rest) {
  1046. if (rest.confirm == true) {
  1047. if (this_[`fileList${event.name}`][event.index].id) {
  1048. removeFile({
  1049. ids: this_[`fileList${event.name}`][event.index].id
  1050. }).then(res => {
  1051. this_[`fileList${event.name}`].splice(event.index, 1)
  1052. })
  1053. } else {
  1054. this_[`fileList${event.name}`].splice(event.index, 1)
  1055. }
  1056. }
  1057. }
  1058. })
  1059. },
  1060. }
  1061. }
  1062. </script>
  1063. <style lang="scss" scoped>
  1064. ::v-deep .u-cell__body {
  1065. padding: 20rpx 10rpx;
  1066. }
  1067. .choice {
  1068. position: fixed;
  1069. right: 10rpx;
  1070. border-radius: 10rpx;
  1071. padding: 0 10rpx 10rpx 10rpx;
  1072. background-color: #fff;
  1073. // #ifdef H5
  1074. top: calc(var(--status-bar-height) + 44px + 20rpx);
  1075. // #endif
  1076. // #ifdef APP-PLUS
  1077. top: 30rpx,
  1078. // #endif
  1079. }
  1080. .mask {
  1081. width: 100%;
  1082. height: 100%;
  1083. position: fixed;
  1084. top: 0;
  1085. bottom: 0;
  1086. background-color: rgba(1, 1, 1, 0.3);
  1087. }
  1088. </style>