index.vue 34 KB

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