index.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <view style="background-color: #f2f2f6;padding-top: 1rpx;">
  3. <u-navbar title="销售" bgColor="#FD4B09" :autoBack="true" :placeholder="true" leftIconColor="#fff"
  4. :titleStyle="{color: '#fff'}">
  5. <view slot="right">
  6. <u-icon name="clock" size="40rpx" color="#fff" @click="historical0rders()"></u-icon>
  7. </view>
  8. </u-navbar>
  9. <view style="padding: 0 10rpx;width:96%;border-radius:10rpx;margin: 20rpx auto;background-color: #fff;">
  10. <u-cell-group :border="false">
  11. <u-cell icon="account" :iconStyle="{color: '#FD4B09'}" title="客户" :value="form.corpName" :isLink="true"
  12. @click="selectCustomer">
  13. </u-cell>
  14. <u-cell icon="account" :iconStyle="{color: '#FD4B09'}" title="联系人" v-model="form.contacts"
  15. :isLink="true" @click="filterAll(['contacts','contacts'])">
  16. </u-cell>
  17. <view style="display: flex;
  18. align-items: center;
  19. justify-content: space-between;
  20. padding: 20rpx 30rpx;
  21. border-bottom: 1px solid #d6d7d9;">
  22. <view style="display: flex;align-items: center;color: #FD4B09;font-size: 30rpx;width: 200rpx;">
  23. <u-icon name="phone" color="#FD4B09"></u-icon>
  24. <text style="margin-left: 8rpx;">电话</text>
  25. </view>
  26. <view>
  27. <u-input v-model="form.phone" inputAlign="right" border="none" placeholder="请填写电话"
  28. disabledColor="#ffffff">
  29. </u-input>
  30. </view>
  31. </view>
  32. <!-- <u-cell icon="phone" :iconStyle="{color: '#FD4B09'}" title="电话" :isLink="true">
  33. <view slot="right-icon">
  34. <u-input v-model="form.phone" inputAlign="right" border="none"
  35. placeholder="请填写电话"
  36. disabledColor="#ffffff">
  37. </u-input>
  38. </view>
  39. </u-cell> -->
  40. <view style="display: flex;
  41. align-items: center;
  42. justify-content: space-between;
  43. padding: 20rpx 30rpx;
  44. border-bottom: 1px solid #d6d7d9;">
  45. <view style="display: flex;align-items: center;color: #FD4B09;font-size: 30rpx;width: 200rpx;">
  46. <u-icon name="map" color="#FD4B09"></u-icon>
  47. <text style="margin-left: 8rpx;">送货地址</text>
  48. </view>
  49. <view style="width: 90%;">
  50. <u--textarea v-model="form.recAddress" autoHeight inputAlign="right" border="none"
  51. placeholder="请填写送货地址" disabledColor="#ffffff">
  52. </u--textarea>
  53. </view>
  54. </view>
  55. <!-- <u-cell icon="map" :iconStyle="{color: '#FD4B09'}" title="送货地址" :isLink="true">
  56. <view slot="right-icon">
  57. <u-input style="width: calc(100% - 400rpx);" v-model="form.recAddress" inputAlign="right" border="none"
  58. placeholder="请填写送货地址"
  59. disabledColor="#ffffff">
  60. </u-input>
  61. </view>
  62. </u-cell> -->
  63. <u-cell icon="account" :iconStyle="{color: '#FD4B09'}" title="业务员" v-model="form.salerName"
  64. :isLink="true" @click="filterAll(['salerName','salerId'])">
  65. </u-cell>
  66. <u-cell icon="calendar" :iconStyle="{color: '#FD4B09'}" title="日期"
  67. :value="form.businesDate?form.businesDate.slice(0,10):''" :isLink="true" @click="show = true">
  68. </u-cell>
  69. <u-cell icon="home" :iconStyle="{color: '#FD4B09'}" title="发货仓库" :value="form.storageName"
  70. :isLink="true" @click="filterAll(['storageName','storageId'])">
  71. </u-cell>
  72. <u-cell icon="car" :iconStyle="{color: '#FD4B09'}" title="配送方式" :value="form.select" :isLink="true"
  73. @click="filterAll(['select','select'])">
  74. </u-cell>
  75. <u-cell icon="home" :iconStyle="{color: '#FD4B09'}" title="物流公司" :value="form.logisticsCorpName"
  76. :isLink="true" @click="filterAll(['logisticsCorpName','logisticsCorpId'])">
  77. </u-cell>
  78. <view style="display: flex;
  79. align-items: center;
  80. justify-content: space-between;
  81. padding: 20rpx 30rpx;
  82. border-bottom: 1px solid #d6d7d9;">
  83. <view style="display: flex;align-items: center;color: #FD4B09;font-size: 30rpx;width: 200rpx;">
  84. <u-icon name="file-text" color="#FD4B09"></u-icon>
  85. <text style="margin-left: 8rpx;">物流单号</text>
  86. </view>
  87. <view>
  88. <u-input v-model="form.expressNo" inputAlign="right" border="none" placeholder="请输入物流单号"
  89. disabledColor="#ffffff">
  90. </u-input>
  91. </view>
  92. </view>
  93. <!-- <u-cell icon="file-text" :iconStyle="{color: '#FD4B09'}" title="物流单号" :isLink="true">
  94. <view slot="right-icon">
  95. <u-input v-model="form.expressNo" inputAlign="right" border="none"
  96. placeholder="请输入物流单号"
  97. disabledColor="#ffffff">
  98. </u-input>
  99. </view>
  100. </u-cell> -->
  101. </u-cell-group>
  102. </view>
  103. <view
  104. style="padding: 0 10rpx;width:96%;border-radius:10rpx;margin: 20rpx auto;background-color: #fff;padding-top: 10rpx;">
  105. <u-cell-group :border="false">
  106. <u-cell icon="list-dot" :iconStyle="{color: '#FD4B09'}"
  107. :title="'产品列表('+dataList.length+') '+' 数量'+ numberAll" value="添加产品">
  108. <view slot="value" class="u-slot-value">
  109. <u-button type="primary" text="添加产品" shape="circle" size="small" color="#FD4B09"
  110. @click="selectProduct()"></u-button>
  111. </view>
  112. </u-cell>
  113. <u-cell v-for="(item,index) in dataList" :key="index" @click="tanchuangxgai(item,index)">
  114. <view slot="label">
  115. <!-- customStyle="margin-bottom: 10px" -->
  116. <u-row>
  117. <u-col span="2.9">
  118. <u--image :showLoading="true"
  119. :src="item.goodsFilesList.length > 0?item.goodsFilesList[0].url:'../../../static/images/404.png'"
  120. width="80px" height="80px" radius="10">
  121. </u--image>
  122. </u-col>
  123. <u-col span="9.1">
  124. <!-- style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" -->
  125. <view style="font-size: 36rpx;">
  126. {{item.cname}}
  127. </view>
  128. <view style="color: #707070;">批次号:{{item.dot}}</view>
  129. <view style="display: flex;justify-content: space-between;">
  130. <view style="color: #707070;">单价:¥{{item.price}}</view>
  131. <view style="color: #707070;">数量:{{item.goodsNum}}</view>
  132. </view>
  133. <view style="display: flex;justify-content: space-between;">
  134. <view style="color: #707070;">金额:¥{{item.amount}}</view>
  135. <view style="color: #707070; color: red;" @click="deleteProduct(index)">
  136. <u-button type="error" size="mini" text="删除"></u-button>
  137. </view>
  138. </view>
  139. </u-col>
  140. </u-row>
  141. </view>
  142. </u-cell>
  143. </u-cell-group>
  144. </view>
  145. <view style="width: 100%;height: 110rpx;"></view>
  146. <view class="submitBar">
  147. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  148. <view style="width: 100%;display: flex;font-size: 24rpx;justify-content: space-between;">
  149. <view style="width: 50%;display: flex;">
  150. <view style="margin-top: 10rpx;">
  151. <u-icon name="shopping-cart" color="#FD4B09" size="50"></u-icon>
  152. </view>
  153. <view style="margin-top: 40rpx;color: #000;">
  154. 金额:<text style="color: red;">¥{{amount}}</text>
  155. </view>
  156. </view>
  157. <view @click="billingCollection"
  158. style="width: 25%;background-color: #5ac725;display: grid;justify-items: center;">
  159. <u-icon name="file-text" color="#fff"></u-icon>
  160. <view style="color: #fff;">开单并生成任务</view>
  161. </view>
  162. <view @click="saveOrder"
  163. style="width: 25%;background-color: #fd4b09;display: grid;justify-items: center;">
  164. <u-icon name="checkmark" color="#fff"></u-icon>
  165. <view style="color: #fff;">确认开单</view>
  166. </view>
  167. </view>
  168. </view>
  169. </view>
  170. <!-- 弹窗数据 -->
  171. <u-popup :show="popupShow" @close="popupShow = false" :closeable="true" mode="center"
  172. customStyle="width: 90%;margin: 0 auto;">
  173. <view style="padding: 40rpx 25rpx;box-sizing: border-box;">
  174. <view style="text-align: center;margin: 10rpx 0;">
  175. <view style="font-size: 36rpx;word-break:break-all;">
  176. {{popupForm.cname}}
  177. </view>
  178. </view>
  179. <view style="width: 96%;margin: 0 auto;clear: both;">
  180. <u-cell-group>
  181. <u-cell title="单价">
  182. <view slot="value">
  183. <u--input type='number' placeholder="请输入单价" border="none" inputAlign="right"
  184. v-model="popupForm.price" clearable disabledColor="#ffffff">
  185. </u--input>
  186. </view>
  187. </u-cell>
  188. <u-cell title="数量">
  189. <view slot="value">
  190. <u-number-box v-model="popupForm.goodsNum" :min="0">
  191. </u-number-box>
  192. </view>
  193. </u-cell>
  194. <u-cell title="批次号(DOT)" @click="dotClickfun">
  195. <view slot="value">
  196. <u--input border="none" inputAlign="right" v-model="popupForm.dot" disabled
  197. placeholder="请选择批次号" disabledColor="#ffffff"></u--input>
  198. </view>
  199. </u-cell>
  200. <u-cell title="库存">
  201. <view slot="value">
  202. {{popupForm.inventory?popupForm.inventory:'--'}}
  203. </view>
  204. </u-cell>
  205. <u-cell title="规格型号">
  206. <view slot="value">
  207. {{popupForm.specificationAndModel?popupForm.specificationAndModel:'--'}}
  208. </view>
  209. </u-cell>
  210. </u-cell-group>
  211. </view>
  212. <view style="margin-top: 40rpx;text-align: center;
  213. font-size: 32rpx;">
  214. <view style="display: flex; color: #fff;justify-content: space-around;">
  215. <view style="color: #FD4B09; border: 1rpx solid #FD4B09;
  216. width: 200rpx; height: 80rpx;
  217. line-height: 80rpx; border-radius: 12rpx;" @click="popupShow = false">取消</view>
  218. <view
  219. style="background-color: #FF6F3B; width: 200rpx; height: 80rpx; line-height: 80rpx; border-radius: 12rpx;"
  220. @click="popupConserve()">保存</view>
  221. </view>
  222. </view>
  223. </view>
  224. </u-popup>
  225. <!-- 批次号弹窗 -->
  226. <u-picker :show="dotPickerShow" :columns="dotPickerColumns" keyName="dot" @confirm="dotPickerConfirm"
  227. @cancel="dotPickerShow = false"></u-picker>
  228. <u-popup zIndex="10070" :closeOnClickOverlay="false" :show="openPopup"
  229. @close="openPopup = false,mask = false,uni.navigateBack()" mode="center" closeable round="10rpx">
  230. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="formTwo" ref="formTwo"
  231. labelWidth="150rpx">
  232. <view style="width: calc(700rpx - 20px);margin: 10px;">
  233. <text>收款台</text>
  234. <view>
  235. <u-form-item label="订单金额" prop="cname" borderBottom>
  236. <u-input type="number" v-model="formTwo.orderAmount" border="none" inputAlign="right"
  237. placeholder="请输入" disabled disabledColor="#ffffff" />
  238. </u-form-item>
  239. <u-form-item label="优惠金额" prop="cname" borderBottom>
  240. <u-input type="number" v-model="formTwo.thisUsedProfit" border="none" inputAlign="right"
  241. placeholder="请输入" disabledColor="#ffffff" @blur="thisUsedProfitchange" />
  242. <!-- @blur="discount(0)" 之前的失焦事件具体干啥的我也不知道,因为他没有写注释 -->
  243. </u-form-item>
  244. <u-form-item label="应收金额" prop="cname" borderBottom>
  245. <u-input type="number" v-model="formTwo.debitAmount" border="none" inputAlign="right"
  246. placeholder="请输入" disabled disabledColor="#ffffff" />
  247. </u-form-item>
  248. <u-form-item label="已收金额" prop="cname" borderBottom>
  249. <u-input type="number" v-model="formTwo.settlmentAmount" border="none" inputAlign="right"
  250. placeholder="请输入" disabled disabledColor="#ffffff" />
  251. </u-form-item>
  252. <u-form-item label="溢付款" prop="cname" borderBottom>
  253. <u-input type="number" v-model="formTwo.overPayment" border="none" inputAlign="right"
  254. disabled disabledColor="#ffffff" />
  255. </u-form-item>
  256. <u-form-item label="会员卡金额" prop="cname" borderBottom labelWidth="190rpx">
  257. <u-input type="digit" v-model="formTwo.memberAmout" border="none" inputAlign="right"
  258. disabledColor="#ffffff" @blur="memberBalancechange">
  259. <template slot="suffix">
  260. <text
  261. style="margin-left: 10rpx; border-left: 1rpx solid #000;padding-left: 10rpx;">余额:{{balanceAmount}}</text>
  262. </template>
  263. </u-input>
  264. </u-form-item>
  265. <u-form-item label="本次收款" prop="cname" borderBottom>
  266. <u-input type="number" clearable v-model="formTwo.currentAmount" border="none"
  267. inputAlign="right" placeholder="请输入" disabledColor="#ffffff" @blur="discount(1)" />
  268. </u-form-item>
  269. <u-form-item label="收款日期" labelWidth="190rpx" prop="cname" borderBottom
  270. @click="filterAll(['advanceCollectionDate','advanceCollectionDate'])">
  271. <view style="width: 100%;text-align: right;">
  272. {{formTwo.advanceCollectionDate?formTwo.advanceCollectionDate.slice(0,10):''}}
  273. </view>
  274. </u-form-item>
  275. <u-form-item label="收款账户" prop="cname" borderBottom @click="filterAll(['account','account'])">
  276. <u-input v-model="formTwo.account" border="none" inputAlign="right" placeholder="请选择"
  277. disabled disabledColor="#ffffff">
  278. <template slot="suffix" style="text-align: center;">
  279. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  280. </template>
  281. </u-input>
  282. </u-form-item>
  283. <view style="display: flex;margin-top: 20rpx;">
  284. <u-button text="取消" style="width: 45%;" @click="quxiaofun"></u-button>
  285. <u-button type="primary" text="收款" color="#FD4B09" style="width: 45%;"
  286. @click="collectionConfirm"></u-button>
  287. </view>
  288. </view>
  289. </view>
  290. </u--form>
  291. </u-popup>
  292. <u-datetime-picker :show="show" v-model="timeValue" mode="date" @confirm="confirm" @cancel="show = false">
  293. </u-datetime-picker>
  294. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false,mask = false"
  295. @confirm="confirmTiem"></u-datetime-picker>
  296. <u-picker :show="showWarehouse" :columns="columns" :defaultIndex="defaultIndex" :keyName="keyName"
  297. @confirm="confirmWarehouse" @cancel="showWarehouse = false"></u-picker>
  298. <u-notify ref="uNotify"></u-notify>
  299. </view>
  300. </template>
  301. <script>
  302. import {
  303. queryBrand
  304. } from '@/api/views/stock/index.js'
  305. import {
  306. customerList,
  307. storageDescListAll,
  308. quickBilling,
  309. corpsDescDetail,
  310. corpsAddrCorpIdByAddr,
  311. stockDescDotList,
  312. isProcurement,
  313. typeSave,
  314. orderGenerateShipTask,
  315. gainUser,
  316. checkOrderRW,
  317. whetherExistenceFinancing
  318. } from '@/api/views/sale/index.js'
  319. import {
  320. collectPayment,
  321. getCorpDesc
  322. } from '@/api/views/sale/salesOrderDetails.js'
  323. import {
  324. dateFormat
  325. } from '@/common/dateFormat'
  326. export default {
  327. data() {
  328. return {
  329. show: false,
  330. timeOpen: false,
  331. openPopup: false,
  332. showWarehouse: false,
  333. timeValue: Number(new Date()),
  334. datetime: Number(new Date()),
  335. columns: [],
  336. dataList: [],
  337. amount: 0.00,
  338. numberAll: 0,
  339. screen: [],
  340. keyName: '',
  341. form: {
  342. corpId: '',
  343. corpName: '',
  344. customer: '',
  345. businesDate: '',
  346. storageName: '',
  347. total: 0
  348. },
  349. formTwo: {},
  350. revenueTop: 0,
  351. // 会员卡余额
  352. balanceAmount: 0,
  353. // 业务员数据
  354. salesmanData: [],
  355. // 发货仓库的数据
  356. warehouseData: [],
  357. // 联系人数据
  358. contactsData: [],
  359. // 产品弹窗暂存的数据
  360. popupForm: {},
  361. popupIndex: 0,
  362. popupShow: false,
  363. // 批次号弹窗
  364. dotPickerShow: false,
  365. dotPickerColumns: [],
  366. // 物流配送方式请求到的数据
  367. selectData: [],
  368. // 物流公司请求的数据
  369. logisticsCorpData: [],
  370. defaultIndex: [0],
  371. }
  372. },
  373. onLoad() {
  374. this.queryBrandfun()
  375. this.HYqueryBrandfun()
  376. uni.getSystemInfo({
  377. success: (e) => {
  378. this.revenueTop = e.statusBarHeight + 44
  379. }
  380. })
  381. },
  382. created() {
  383. // 赋值默认时间,当天时间
  384. this.form.businesDate = new Date((new Date()).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ')
  385. .substr(0, 19);
  386. // 业务员
  387. // this.form.salesName = uni.getStorageSync('userInfo').user_id
  388. // this.form.sales = uni.getStorageSync('userInfo').user_name
  389. // 赋值第一项当作默认值
  390. storageDescListAll().then(res => {
  391. this.warehouseData = res.data
  392. if (res.data.length > 0) {
  393. this.form.storageName = res.data[0].cname
  394. this.form.storageId = res.data[0].id
  395. }
  396. })
  397. gainUser({
  398. roleName: '业务员'
  399. }).then(res => {
  400. this.salesmanData = res.data
  401. if (res.data.length > 0) {
  402. this.$set(this.form, 'salerName', res.data[0].name)
  403. this.$set(this.form, 'salerId', res.data[0].id)
  404. }
  405. })
  406. },
  407. methods: {
  408. // 优惠金额的监听
  409. thisUsedProfitchange(value) {
  410. // 订单金额
  411. this.formTwo.orderAmount = this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0
  412. // 优惠金额
  413. this.formTwo.thisUsedProfit = this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0
  414. // 已收金额
  415. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  416. // 应收金额
  417. this.formTwo.debitAmount = this.formTwo.debitAmount ? Number(this.formTwo.debitAmount) : 0
  418. // 会员卡金额
  419. this.formTwo.memberAmout = this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  420. if (this.formTwo.thisUsedProfit < 0) {
  421. this.$refs.uToast.show({
  422. type: 'error',
  423. icon: false,
  424. message: "优惠金额不能小于零",
  425. })
  426. this.formTwo.thisUsedProfit = 0
  427. }
  428. if (this.formTwo.thisUsedProfit > this.formTwo.orderAmount) {
  429. this.$refs.uToast.show({
  430. type: 'error',
  431. icon: false,
  432. message: "优惠金额不能大于订单金额",
  433. })
  434. this.formTwo.thisUsedProfit = 0
  435. }
  436. // this.formTwo.currentAmount =
  437. this.formTwo.debitAmount = this.formTwo.orderAmount - this.formTwo.thisUsedProfit
  438. },
  439. // 会员卡收款监听事件
  440. memberBalancechange(value) {
  441. // 订单金额
  442. this.formTwo.orderAmount = this.formTwo.orderAmount ? Number(this.formTwo.orderAmount) : 0
  443. // 优惠金额
  444. this.formTwo.thisUsedProfit = this.formTwo.thisUsedProfit ? Number(this.formTwo.thisUsedProfit) : 0
  445. // 已收金额
  446. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  447. // 应收金额
  448. this.formTwo.debitAmount = this.formTwo.debitAmount ? Number(this.formTwo.debitAmount) : 0
  449. // 会员卡金额
  450. this.formTwo.memberAmout = this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  451. if (this.formTwo.memberAmout < 0) {
  452. this.$delete(this.formTwo, 'memberAmout')
  453. this.$set(this.formTwo, 'memberAmout', 0)
  454. this.$refs.uToast.show({
  455. type: 'error',
  456. icon: false,
  457. message: "会员卡金额不能小于零",
  458. })
  459. // this.formTwo.memberAmout = 0
  460. }
  461. if (this.formTwo.memberAmout >= this.balanceAmount) {
  462. this.$delete(this.formTwo, 'memberAmout')
  463. this.$set(this.formTwo, 'memberAmout', this.balanceAmount)
  464. // this.formTwo.memberAmout = this.balanceAmount
  465. this.formTwo.currentAmount = 0
  466. this.$refs.uToast.show({
  467. type: 'error',
  468. icon: false,
  469. message: "会员卡金额不能大于余额",
  470. })
  471. }
  472. const curr = this.formTwo.debitAmount - this.formTwo.settlmentAmount
  473. if (this.formTwo.memberAmout > curr) {
  474. // this.formTwo.memberAmout = curr
  475. this.$delete(this.formTwo, 'memberAmout')
  476. this.$set(this.formTwo, 'memberAmout', curr)
  477. }
  478. this.formTwo.currentAmount = this.formTwo.debitAmount - this.formTwo.settlmentAmount - this.formTwo
  479. .memberAmout
  480. },
  481. newCompany() {
  482. uni.$u.route('/pages/views/product/createCompany', {
  483. code: "account",
  484. title: "收款账户"
  485. });
  486. },
  487. //时间确认选择
  488. confirmTiem(e) {
  489. this.formTwo[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  490. this.timeOpen = false
  491. this.mask = false
  492. },
  493. // 开单弹窗取消
  494. quxiaofun() {
  495. this.openPopup = false,
  496. this.mask = false,
  497. uni.navigateBack()
  498. },
  499. // 收款
  500. collectionConfirm() {
  501. if (!this.formTwo.orderAmount) {
  502. return uni.showToast({
  503. icon: "none",
  504. title: '合同金额不能为空',
  505. mask: true
  506. });
  507. }
  508. // 判断本次收款和会员卡收款不能为空
  509. if (!this.formTwo.currentAmount || this.formTwo.currentAmount == 0) {
  510. if (!this.formTwo.memberAmout || this.formTwo.memberAmout == 0) {
  511. return uni.showToast({
  512. icon: "none",
  513. title: '本次收款金额或会员卡金额不能为空或零',
  514. mask: true
  515. });
  516. }
  517. }
  518. if (!this.formTwo.account) {
  519. return uni.showToast({
  520. icon: "none",
  521. title: '收款帐户不能为空',
  522. mask: true
  523. });
  524. }
  525. let this_ = this
  526. uni.showModal({
  527. title: '是否确认收款',
  528. content: '本次收款金额' + this_.formTwo.currentAmount + '会员卡收款金额' + this_.formTwo.memberAmout,
  529. success: function(rest) {
  530. if (rest.confirm == true) {
  531. uni.showLoading({
  532. title: '加载中',
  533. mask: true
  534. });
  535. collectPayment(this_.formTwo).then(res => {
  536. uni.showToast({
  537. icon: "none",
  538. title: '收款成功',
  539. mask: true,
  540. duration: 2000
  541. });
  542. this.openPopup = false
  543. setTimeout(function() {
  544. uni.hideLoading();
  545. uni.navigateBack();
  546. }, 2000);
  547. })
  548. }
  549. }
  550. })
  551. },
  552. //集合筛选条件
  553. filterAll(screen) {
  554. this.screen = screen
  555. switch (screen[1]) {
  556. case "account":
  557. this.$u.api.getWorkDicts('account').then(res => {
  558. this.columns = [res.data]
  559. this.defaultIndex = [0]
  560. this.keyName = "dictValue"
  561. this.showWarehouse = true
  562. })
  563. break;
  564. case "advanceCollectionDate":
  565. this.timeOpen = true
  566. this.mask = true
  567. break;
  568. case "storageId":
  569. this.columns = [this.warehouseData]
  570. this.defaultIndex = [0]
  571. this.keyName = 'cname'
  572. this.showWarehouse = true
  573. break;
  574. case "salerId":
  575. this.columns = [this.salesmanData]
  576. this.defaultIndex = [0]
  577. this.keyName = 'name'
  578. this.showWarehouse = true
  579. break;
  580. case "contacts":
  581. if (!this.form.corpId) return this.$refs.uNotify.show({
  582. top: this.revenueTop,
  583. type: 'warning',
  584. message: '请选择客户!'
  585. })
  586. this.columns = [this.contactsData]
  587. this.defaultIndex = [0]
  588. this.keyName = 'contacts'
  589. this.showWarehouse = true
  590. break;
  591. // 配送方式
  592. case "select":
  593. this.columns = [this.selectData]
  594. this.defaultIndex = [0]
  595. this.keyName = 'dictValue'
  596. this.showWarehouse = true
  597. break;
  598. // 物流公司
  599. case "logisticsCorpId":
  600. this.columns = [this.logisticsCorpData]
  601. this.defaultIndex = [0]
  602. this.keyName = 'dictValue'
  603. this.showWarehouse = true
  604. break;
  605. }
  606. },
  607. discount(type) {
  608. if (type == 0) {
  609. if (this.formTwo.thisUsedProfit < 0) {
  610. return this.formTwo.thisUsedProfit = null
  611. }
  612. this.formTwo.orderAmount = (this.formTwo.costAmount - this.formTwo.thisUsedProfit).toFixed(2)
  613. this.formTwo.currentAmount = this.formTwo.orderAmount
  614. if (this.formTwo.orderAmount < 0) {
  615. this.$set(this.formTwo, "orderAmount", null)
  616. this.$set(this.formTwo, "thisUsedProfit", null)
  617. uni.showToast({
  618. icon: "none",
  619. title: '优惠金额不能大于订单金额',
  620. mask: true
  621. });
  622. }
  623. if ((this.formTwo.currentAmount - this.formTwo.orderAmount) > 0) {
  624. this.formTwo.overPayment = (this.formTwo.currentAmount - this.formTwo.orderAmount).toFixed(2)
  625. } else {
  626. this.formTwo.overPayment = '0.00'
  627. }
  628. } else if (type == 1) {
  629. // 已收金额
  630. this.formTwo.settlmentAmount = this.formTwo.settlmentAmount ? Number(this.formTwo.settlmentAmount) : 0
  631. // 应收金额
  632. this.formTwo.debitAmount = this.formTwo.debitAmount ? Number(this.formTwo.debitAmount) : 0
  633. this.formTwo.memberAmout = this.formTwo.memberAmout ? Number(this.formTwo.memberAmout) : 0
  634. this.formTwo.currentAmount = this.formTwo.currentAmount ? Number(this.formTwo.currentAmount) : 0
  635. console.log((this.formTwo.debitAmount - this.formTwo.settlmentAmount - this.formTwo.memberAmout), 353);
  636. if (this.formTwo.currentAmount > (this.formTwo.debitAmount - this.formTwo.settlmentAmount - this
  637. .formTwo.memberAmout)) {
  638. this.$refs.uToast.show({
  639. type: 'error',
  640. icon: false,
  641. message: "收款和会员卡金额不能大于应收金额",
  642. })
  643. this.formTwo.currentAmount = 0
  644. }
  645. if (this.formTwo.currentAmount < 0) {
  646. return this.formTwo.currentAmount = 0
  647. }
  648. }
  649. },
  650. // 产品删除
  651. deleteProduct(index) {
  652. this.amount = Number(this.amount) - Number(this.dataList[index].amount)
  653. this.amount.toFixed(2)
  654. this.dataList.splice(index, 1)
  655. this.numberAll = 0
  656. for (let item of this.dataList) {
  657. this.numberAll += Number(item.goodsNum)
  658. }
  659. },
  660. //客户选择跳转回来触发
  661. otherFun(customer) {
  662. console.log(customer, 495);
  663. this.form.corpName = customer.cname
  664. this.form.corpId = customer.id
  665. this.form.salerId = customer.salesmanId
  666. this.form.salerName = ''
  667. this.salesmanData.map(item => {
  668. if (item.id == this.form.salerId) {
  669. this.form.salerName = item.name
  670. }
  671. })
  672. this.form.storageName = ''
  673. this.form.storageId = customer.deliveryWarehouseId
  674. this.warehouseData.map(item => {
  675. if (item.id == this.form.storageId) {
  676. this.form.storageName = item.cname
  677. }
  678. })
  679. this.corpsAddrCorpIdByAddrfun()
  680. // corpsDescDetail({id:customer.id}).then(res=>{
  681. // console.log(res,517);
  682. // this.form.contacts = res.data.corpsAddrList[0].contacts
  683. // this.form.recAddress = res.data.corpsAddrList[0].belongtoarea + res.data.corpsAddrList[0].detailedAddress
  684. // this.form.phone = res.data.corpsAddrList[0].tel
  685. // })
  686. // this.form.belongToCorpId = customer.belongtocompany
  687. },
  688. // 获取联系人数据 赋值第一项
  689. corpsAddrCorpIdByAddrfun() {
  690. corpsAddrCorpIdByAddr({
  691. pid: this.form.corpId
  692. }).then(res => {
  693. this.contactsData = res.data
  694. this.$set(this.form, 'contacts', this.contactsData[0].contacts)
  695. this.$set(this.form, 'recAddress', this.contactsData[0].address)
  696. this.$set(this.form, 'phone', this.contactsData[0].tel)
  697. })
  698. },
  699. //商品跳转选择完成返回
  700. getProduct(dataList) {
  701. this.amount = Number(this.amount)
  702. for (let item of dataList) {
  703. this.dataList.push(item)
  704. this.amount += Number(item.amount)
  705. this.numberAll += Number(item.goodsNum)
  706. }
  707. this.amount = this.amount.toFixed(2)
  708. },
  709. // 客户跳转
  710. selectCustomer() {
  711. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  712. corpType: 'KH'
  713. });
  714. },
  715. historical0rders() {
  716. this.$u.route('/pages/views/salesSlip/salesOrderList');
  717. },
  718. // 获取物流配送方式数据
  719. queryBrandfun() {
  720. queryBrand({
  721. code: 'deliveryMethod'
  722. }).then(res => {
  723. this.selectData = res.data
  724. })
  725. },
  726. // 获取货运公司数据
  727. HYqueryBrandfun() {
  728. queryBrand({
  729. code: 'tyre_express_company'
  730. }).then(res => {
  731. this.logisticsCorpData = res.data
  732. })
  733. },
  734. // 批次号打开弹窗按钮 获取批次号数据
  735. dotClickfun() {
  736. this.dotPickerShow = true
  737. stockDescDotList({
  738. storageId: this.form.storageId,
  739. goodsId: this.popupForm.goodsId
  740. }).then(res => {
  741. this.dotPickerColumns = [res.data]
  742. })
  743. },
  744. // 批次号弹窗的确认
  745. dotPickerConfirm(e) {
  746. this.popupForm.dot = e.value[0].dot
  747. this.dotPickerShow = false
  748. },
  749. // 产品弹窗编辑
  750. tanchuangxgai(row, index) {
  751. this.popupForm = row
  752. this.popupIndex = index
  753. this.popupShow = true
  754. },
  755. //修改弹窗点击保存事件
  756. popupConserve() {
  757. if (this.popupForm.whether == 1) {
  758. if (!this.popupForm.dot) {
  759. return uni.showToast({
  760. icon: 'none',
  761. title: '批次号必填',
  762. position: "bottom"
  763. })
  764. }
  765. }
  766. if (!this.popupForm.goodsNum) {
  767. return uni.showToast({
  768. icon: 'none',
  769. title: '数量不能为0',
  770. position: "bottom"
  771. })
  772. }
  773. this.popupForm.amount = (Number(this.popupForm.price) * Number(this.popupForm.goodsNum)).toFixed(2);
  774. this.dataList[this.popupIndex] = this.popupForm
  775. this.amount = 0
  776. for (let item of this.dataList) {
  777. this.amount = (Number(this.amount) + Number(item.amount)).toFixed(2)
  778. }
  779. uni.hideLoading();
  780. this.popupShow = false
  781. },
  782. // 添加产品跳转
  783. selectProduct() {
  784. if (!this.form.corpId) return this.$refs.uNotify.show({
  785. top: this.revenueTop,
  786. type: 'warning',
  787. message: '请选择客户!'
  788. })
  789. if (this.form.storageId) {
  790. this.$u.route('/pages/views/salesSlip/selectProduct', {
  791. form: JSON.stringify(this.form),
  792. data: JSON.stringify(this.dataList),
  793. corpId: this.form.corpId
  794. });
  795. } else {
  796. this.$refs.uNotify.show({
  797. top: this.revenueTop,
  798. type: 'warning',
  799. message: '请选择发货仓库!'
  800. })
  801. }
  802. },
  803. confirm(e) {
  804. this.show = false
  805. this.form.businesDate = new Date((new Date(e.value)).getTime() + 8 * 60 * 60 * 1000).toJSON().split('T')
  806. .join(' ').substr(0, 19)
  807. },
  808. confirmWarehouse(e) {
  809. if (this.screen[1] == "account") {
  810. this.formTwo.account = e.value[0].dictValue
  811. this.showWarehouse = false
  812. } else if (this.screen[1] == "salerId") {
  813. this.form.salerName = e.value[0].name
  814. this.form.salerId = e.value[0].id
  815. this.showWarehouse = false
  816. } else if (this.screen[1] == "contacts") {
  817. this.form.contacts = e.value[0].contacts
  818. this.form.recAddress = e.value[0].address
  819. this.form.phone = e.value[0].tel
  820. this.showWarehouse = false
  821. } else if (this.screen[1] == "select") {
  822. this.form.select = e.value[0].dictValue
  823. this.showWarehouse = false
  824. } else if (this.screen[1] == "logisticsCorpId") {
  825. this.form.logisticsCorpId = e.value[0].dictKey
  826. this.form.logisticsCorpName = e.value[0].dictValue
  827. this.showWarehouse = false
  828. } else if (this.screen[1] == "storageId") {
  829. this.form.storageName = e.value[0].cname
  830. this.form.storageId = e.value[0].id
  831. this.showWarehouse = false
  832. } else {
  833. console.log(123);
  834. }
  835. },
  836. //开单收款
  837. billingCollection() {
  838. uni.showModal({
  839. title: '提示',
  840. content: '是否要开单并生成任务',
  841. success: (rest) => {
  842. if (rest.confirm == true) {
  843. this.saveOrder('生成任务')
  844. }
  845. }
  846. })
  847. },
  848. //保存订单
  849. saveOrder(zhuangtai) {
  850. if (!this.form.corpId) return this.$refs.uNotify.show({
  851. top: this.revenueTop,
  852. type: 'warning',
  853. message: '请选择客户!'
  854. })
  855. if (!this.form.salerName) return this.$refs.uNotify.show({
  856. top: this.revenueTop,
  857. type: 'warning',
  858. message: '请选择业务员!'
  859. })
  860. if (!this.form.businesDate) return this.$refs.uNotify.show({
  861. top: this.revenueTop,
  862. type: 'warning',
  863. message: '请选择日期!'
  864. })
  865. if (!this.form.storageId) return this.$refs.uNotify.show({
  866. top: this.revenueTop,
  867. type: 'warning',
  868. message: '请选择发货仓库!'
  869. })
  870. if (this.dataList.length == 0) return this.$refs.uNotify.show({
  871. top: this.revenueTop,
  872. type: 'warning',
  873. message: '请选择产品!'
  874. })
  875. // if (!this.form.select) {
  876. // return this.$refs.uNotify.show({
  877. // top: this.revenueTop,
  878. // type: 'warning',
  879. // message: '请选择配送方式!'
  880. // })
  881. // }
  882. // if (!this.form.logisticsCorpId) {
  883. // return this.$refs.uNotify.show({
  884. // top: this.revenueTop,
  885. // type: 'warning',
  886. // message: '请选择物流公司!'
  887. // })
  888. // }
  889. // if (!this.form.expressNo) {
  890. // return this.$refs.uNotify.show({
  891. // top: this.revenueTop,
  892. // type: 'warning',
  893. // message: '请输入物流单号!'
  894. // })
  895. // }
  896. let arr = this.dataList.map(item => {
  897. return {
  898. brandId: item.brandId,
  899. brandName: item.brandName,
  900. goodsId: item.id,
  901. price: item.price,
  902. goodsName: item.cname,
  903. goodsNum: item.goodsNum,
  904. goodsNo: item.code,
  905. propertyName: item.specificationAndModel,
  906. dot: item.dot,
  907. whether: item.whether,
  908. units: item.unit,
  909. goodsDescription: item.goodsDescription,
  910. inventory: item.inventory,
  911. pattern: item.brandItem,
  912. subTotalMoney: item.goodsNum * item.price, // 小计
  913. remarks: item.remarks, // 备注
  914. dotedittype: false, // 批次号的状态
  915. goodsNumtype: false, // 价格数量
  916. pricetype: false, // 价格
  917. }
  918. })
  919. let form = {
  920. bsType: 'XS',
  921. businessSource: '内部销售',
  922. cost: '',
  923. freight: '',
  924. grossProfit: '',
  925. ordNo: '',
  926. paymentAmountTl: '',
  927. salesAmount: '',
  928. srcOrdNo: '',
  929. totalMoney: '',
  930. contacts: this.form.contacts, // 联系人
  931. orderItemsList: arr,
  932. phone: this.form.phone, // 电话
  933. recAddress: this.form.recAddress, // 地址
  934. customerId: this.form.corpId,
  935. businesDate: this.form.businesDate,
  936. receivableType: '网络支付',
  937. remarks: '', // 备注
  938. salerId: this.form.salerId,
  939. salerName: this.form.salerName,
  940. shipType: this.form.select,
  941. storageId: this.form.storageId,
  942. expressNo: this.form.expressNo,
  943. logisticsCorpId: this.form.logisticsCorpId,
  944. logisticsCorpName: this.form.logisticsCorpName,
  945. select: this.form.select
  946. }
  947. uni.showLoading({
  948. title: '加载中',
  949. mask: true
  950. });
  951. // typeSave(暂存方法)
  952. quickBilling(form).then(res => {
  953. if (zhuangtai == '生成任务') {
  954. isProcurement({
  955. param: "whether.financing"
  956. }).then(res2 => {
  957. if (res2.data == 1) {
  958. if (!this.form.storageId) {
  959. setTimeout(function() {
  960. uni.hideLoading();
  961. // uni.navigateBack();
  962. }, 1000);
  963. return this.$refs.uNotify.show({
  964. top: this.revenueTop,
  965. type: 'warning',
  966. message: '请选择发货仓库!'
  967. })
  968. } else {
  969. this.whetherExistenceFinancingFun(res.data)
  970. }
  971. } else {
  972. this.orderGenerateShipTaskfun(res.data)
  973. }
  974. })
  975. } else {
  976. uni.showToast({
  977. icon: "none",
  978. title: '开单成功',
  979. mask: true
  980. });
  981. setTimeout(function() {
  982. uni.hideLoading();
  983. uni.navigateBack();
  984. }, 1000);
  985. }
  986. })
  987. },
  988. whetherExistenceFinancingFun(form) {
  989. whetherExistenceFinancing({
  990. bsType: "XS",
  991. ...form
  992. }).then(res => {
  993. if (res.data == true) {
  994. this.orderGenerateShipTaskfun(form)
  995. } else {
  996. uni.showModal({
  997. title: '提示',
  998. content: res.data,
  999. success: (rest) => {
  1000. if (rest.confirm == true) {
  1001. checkOrderRW({
  1002. bsType: "XS",
  1003. ...form,
  1004. url: '/tirePartsMall/salesManagement/saleOrder/index',
  1005. pageStatus: "this.$store.getters.ltxsStatus",
  1006. pageLabel: "销售订单(L)",
  1007. }).then(res => {
  1008. uni.showToast({
  1009. icon: "none",
  1010. title: '生成任务成功',
  1011. mask: true
  1012. });
  1013. setTimeout(function() {
  1014. uni.hideLoading();
  1015. uni.navigateBack();
  1016. }, 1000);
  1017. })
  1018. }
  1019. }
  1020. })
  1021. }
  1022. })
  1023. }, // 生成任务接口
  1024. orderGenerateShipTaskfun(form) {
  1025. orderGenerateShipTask({
  1026. bsType: "XS",
  1027. ...form
  1028. }).then(res => {
  1029. uni.showToast({
  1030. icon: "none",
  1031. title: '生成任务成功',
  1032. mask: true
  1033. });
  1034. setTimeout(function() {
  1035. uni.hideLoading();
  1036. uni.navigateBack();
  1037. }, 1000);
  1038. })
  1039. },
  1040. }
  1041. }
  1042. </script>
  1043. <style scoped>
  1044. .submitBar {
  1045. width: 100%;
  1046. position: fixed;
  1047. bottom: 0rpx;
  1048. padding-bottom: 20rpx;
  1049. font-size: 32rpx;
  1050. color: #000;
  1051. text-align: center;
  1052. border-top: 2rpx solid #f2f2f6;
  1053. background-color: #fff;
  1054. }
  1055. ::v-deep .u-navbar__content {
  1056. background-image: linear-gradient(to bottom, #FD4B09, #FF6F3B);
  1057. }
  1058. ::v-deep .u-cell__title-text {
  1059. color: #FD4B09;
  1060. }
  1061. </style>