aiiReceivables.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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" :value="form.balanceAmount">
  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="corpName" borderBottom>
  13. <u-input v-model="form.corpName" inputAlign="right" border="none" placeholder="请选择" disabled
  14. disabledColor="#ffffff" />
  15. </u-form-item>
  16. <u-form-item label="收款日期" prop="settlementDate" borderBottom
  17. @click="filterAll(['settlementDate','settlementDate'])">
  18. <view style="width: 100%;text-align: right;">
  19. {{form.settlementDate?form.settlementDate.slice(0,10):''}}
  20. </view>
  21. </u-form-item>
  22. <u-form-item label="收款单号" prop="sysNo" borderBottom>
  23. <u-input v-model="form.sysNo" border="none" inputAlign="right" disabled
  24. disabledColor="#ffffff" />
  25. </u-form-item>
  26. <u-form-item label="溢付款" prop="caseOverPayment" borderBottom>
  27. <u-input v-model="form.caseOverPayment" border="none" inputAlign="right" disabled
  28. disabledColor="#ffffff" />
  29. </u-form-item>
  30. <u-form-item label="收款金额" prop="amount" borderBottom>
  31. <u-input v-model="form.amount" border="none" inputAlign="right" placeholder="请输入"
  32. disabledColor="#ffffff" type="number" @blur="divideEqually" />
  33. </u-form-item>
  34. <u-form-item label="收款账户" prop="account" borderBottom @click="filterAll(['account','account'])">
  35. <u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
  36. disabledColor="#ffffff">
  37. <template slot="suffix" style="text-align: center;">
  38. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  39. </template>
  40. </u-input>
  41. </u-form-item>
  42. </view>
  43. </view>
  44. <view
  45. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  46. <u-cell-group :border="false">
  47. <u-cell :border="false" center title="收款列表">
  48. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  49. <view slot="value">
  50. <view style="font-size: 14rpx;">未收总额¥<view
  51. style="display: initial;font-size: 28rpx;font-weight: bold">{{amount}}
  52. </view>
  53. </view>
  54. </view>
  55. <u-icon slot="right-icon" name="arrow-right"></u-icon>
  56. </u-cell>
  57. </u-cell-group>
  58. <u-checkbox-group v-model="checkboxValue" @change="checkboxChange" placement="column">
  59. <view class="contentBox" v-for="(item,index) in orderList" :key="index">
  60. <view class="textBox">
  61. <view>{{item.srcSysno}}</view>
  62. <view>
  63. <u-checkbox :customStyle="{marginBottom: '8px'}" :name="item.id" activeColor="#fd4b09">
  64. </u-checkbox>
  65. </view>
  66. </view>
  67. <view class="textBox">
  68. <view>销售金额:¥{{item.amount}}</view>
  69. <view>销售日期:{{item.accDate?item.accDate.slice(0,10):''}}</view>
  70. </view>
  71. <view class="textBox" style="margin-top: -10rpx;">
  72. <view style="margin-top: 7.5rpx;">未收金额:¥{{item.outstandingAmount}}</view>
  73. <view style="display: flex;">
  74. <u-input placeholder="请输入" type="number" @change="thisTime(item)" v-model="item.currentAmount"
  75. inputAlign="right" fontSize="24rpx" border="none" :customStyle="{
  76. width: '225rpx',
  77. padding: '0'
  78. }">
  79. <text slot="prefix">本次收款:¥</text>
  80. </u-input>
  81. </view>
  82. </view>
  83. </view>
  84. </u-checkbox-group>
  85. </view>
  86. <view
  87. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  88. <u-cell-group :border="false">
  89. <u-cell :border="false" center title="图片信息" arrow-direction="down">
  90. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  91. </u-cell>
  92. </u-cell-group>
  93. <view style="padding: 0 10rpx;">
  94. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  95. :maxCount="10"></u-upload>
  96. </view>
  97. </view>
  98. </u--form>
  99. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;">
  100. <view style="width: 100%;display: flex;font-size: 24rpx;padding-bottom: 30rpx;padding-top: 10rpx;"
  101. @click="submit">
  102. <view style="width: 96%;margin: 0 auto;">
  103. <view
  104. style="width: 100%;background-color: #fd4b09;border-radius: 100rpx;display: grid;justify-items: center;padding: 5rpx 0;">
  105. <u-icon name="checkmark" color="#fff"></u-icon>
  106. <view style="color: #fff;">确认收款</view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  112. @confirm="confirmTiem"></u-datetime-picker>
  113. <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
  114. @confirm="showPicker"></u-picker>
  115. </view>
  116. </template>
  117. <script>
  118. import {
  119. queryList,
  120. getSubmit
  121. } from '@/api/views/sale/aiiReceivables.js'
  122. import {
  123. dateFormat
  124. } from '@/common/dateFormat.js'
  125. export default {
  126. data() {
  127. return {
  128. form: {},
  129. formTwo: {},
  130. columns: [],
  131. orderList: [],
  132. fileList1: [],
  133. checkboxValue: [],
  134. timeOpen: false,
  135. showOpen: false,
  136. datetime: Number(new Date()),
  137. amount: 0,
  138. }
  139. },
  140. onLoad(data) {
  141. this.form = {
  142. corpName: data.corpsName,
  143. corpId:data.corpId,
  144. settlementDate: dateFormat(new Date()),
  145. balanceAmount: data.balanceAmount,
  146. srcOrderno:data.sysNo
  147. }
  148. queryList({
  149. corpId: data.corpId,
  150. billType: "XS",
  151. tradeType: "YPJ"
  152. }).then(res => {
  153. this.orderList = res.data
  154. for (let item of res.data) {
  155. this.amount += Number(item.outstandingAmount)
  156. }
  157. this.amount = this.amount.toFixed(2)
  158. })
  159. },
  160. methods: {
  161. newCompany() {
  162. uni.$u.route('/pages/views/product/createCompany',{
  163. code:"account",
  164. title:"收款账户"
  165. });
  166. },
  167. submit() {
  168. let accList = []
  169. for (let item of this.orderList) {
  170. for (let li of this.checkboxValue) {
  171. if(item.id == li){
  172. if(item.currentAmount == 0){
  173. return uni.showToast({
  174. icon: "none",
  175. title: '本次收款金额不能为0',
  176. mask: true
  177. });
  178. }
  179. accList.push(item)
  180. }
  181. }
  182. }
  183. if(accList.length == 0){
  184. return uni.showToast({
  185. icon: "none",
  186. title: '未选择收款',
  187. mask: true
  188. });
  189. }
  190. if(!this.form.account){
  191. return uni.showToast({
  192. icon: "none",
  193. title: '未选择收款账户',
  194. mask: true
  195. });
  196. }
  197. let this_ = this
  198. let form = {
  199. ...this.form,
  200. dc:"D",
  201. itemType:"YPJ",
  202. billType:"D",
  203. filesList:this.fileList1,
  204. accList:accList
  205. }
  206. uni.showModal({
  207. title: '提示',
  208. content: '是否确认提交对账',
  209. success: function(rest) {
  210. if (rest.confirm == true) {
  211. uni.showLoading({
  212. title: '加载中',
  213. mask: true
  214. });
  215. getSubmit(form).then(res=>{
  216. uni.showToast({
  217. icon: "none",
  218. title: '操作成功',
  219. mask: true
  220. });
  221. setTimeout(function() {
  222. uni.hideLoading();
  223. uni.navigateBack();
  224. }, 1500);
  225. })
  226. }
  227. }
  228. })
  229. },
  230. thisTime(item) {
  231. if (item.currentAmount < 0) {
  232. uni.showToast({
  233. icon: "none",
  234. title: '不能输入负数',
  235. mask: true
  236. });
  237. return item.currentAmount = 0
  238. }
  239. let amount = 0.00
  240. let amountTwo = 0.00
  241. for (let li of this.orderList) {
  242. amountTwo += Number(li.currentAmount)
  243. }
  244. if((Number(amountTwo) > Number(this.form.amount)) || !this.form.amount){
  245. this.form.amount = amountTwo
  246. }
  247. for (let li of this.orderList) {
  248. for(let ul of this.checkboxValue)
  249. if(li.id == ul){
  250. amount += Number(li.outstandingAmount)
  251. }
  252. }
  253. if(Number(this.form.amount) > Number(amount)){
  254. this.form.caseOverPayment = Number(this.form.amount) - Number(amount)
  255. this.form.caseOverPayment = this.form.caseOverPayment.toFixed(2)
  256. }else{
  257. this.form.caseOverPayment = 0.00
  258. }
  259. if (item.currentAmount) {
  260. for (let otem of this.checkboxValue) {
  261. if (otem == item.id) return
  262. }
  263. this.checkboxValue.push(item.id)
  264. } else {
  265. for (let otem in this.checkboxValue) {
  266. if (this.checkboxValue[otem] == item.id) return this.checkboxValue.splice(otem, 1)
  267. }
  268. }
  269. },
  270. checkboxChange(e) {
  271. let amount = 0.00
  272. if (e.length > 0) {
  273. for (let item of this.orderList) {
  274. for (let em of e) {
  275. if (em == item.id) {
  276. console.log(Number(item.currentAmount) , Number(item.outstandingAmount))
  277. if(Number(item.currentAmount) <= Number(item.outstandingAmount) || item.currentAmount == null){
  278. item.currentAmount = Number(item.outstandingAmount).toFixed(2)
  279. }
  280. if(Number(item.outstandingAmount) < Number(item.currentAmount)){
  281. amount += Number(item.currentAmount)
  282. }else{
  283. amount += Number(item.outstandingAmount)
  284. }
  285. break
  286. } else {
  287. item.currentAmount = null
  288. }
  289. }
  290. }
  291. // for (let li of this.orderList) {
  292. // amount += Number(li.currentAmount)
  293. // }
  294. if (this.form.amount <= Number(this.form.amount) + Number(amount).toFixed(2) || !this.form.amount) {
  295. this.form.amount = Number(amount).toFixed(2)
  296. }
  297. let i = 0.00
  298. for (let li of this.orderList) {
  299. for(let ul of e)
  300. if(li.id == ul){
  301. i += Number(li.outstandingAmount)
  302. }
  303. }
  304. if(Number(i) - Number(this.form.amount) < 0){
  305. this.form.caseOverPayment = Number(this.form.amount) - Number(i)
  306. }else{
  307. this.form.caseOverPayment = '0.00'
  308. }
  309. } else {
  310. this.form.caseOverPayment = '0.00'
  311. for (let item of this.orderList) {
  312. item.currentAmount = ''
  313. this.form.amount = ''
  314. }
  315. }
  316. },
  317. //平均分配
  318. divideEqually() {
  319. let amount = Number(this.form.amount)
  320. // if(!amount) return
  321. this.checkboxValue = []
  322. if (this.form.amount < 0) {
  323. uni.showToast({
  324. icon: "none",
  325. title: '不能输入负数',
  326. mask: true
  327. });
  328. return this.form.amount = 0
  329. }
  330. for (let item of this.orderList) {
  331. if (Number(amount) - Number(item.outstandingAmount) >= 0) {
  332. item.currentAmount = Number(item.outstandingAmount).toFixed(2)
  333. amount = Number(amount) - Number(item.outstandingAmount)
  334. this.checkboxValue.push(item.id)
  335. } else {
  336. if (amount == 0) {
  337. item.currentAmount = ''
  338. } else {
  339. item.currentAmount = amount.toFixed(2)
  340. this.checkboxValue.push(item.id)
  341. amount = 0
  342. }
  343. }
  344. }
  345. this.form.caseOverPayment = amount.toFixed(2)
  346. },
  347. //集合筛选条件
  348. filterAll(screen) {
  349. this.screen = screen
  350. switch (screen[1]) {
  351. case "settlementDate":
  352. this.timeOpen = true
  353. break;
  354. case "account":
  355. this.$u.api.getWorkDicts('account').then(res => {
  356. this.columns = [res.data]
  357. this.showOpen = true
  358. })
  359. break;
  360. }
  361. },
  362. // 下拉选择
  363. showPicker(e) {
  364. this.form[this.screen[1]] = e.value[0].dictValue
  365. this.showOpen = false
  366. },
  367. //时间确认选择
  368. confirmTiem(e) {
  369. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  370. this.timeOpen = false
  371. },
  372. // 新增图片
  373. async afterRead(event) {
  374. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  375. let lists = [].concat(event.file)
  376. let fileListLen = this[`fileList${event.name}`].length
  377. lists.map((item) => {
  378. this[`fileList${event.name}`].push({
  379. ...item,
  380. status: 'uploading',
  381. message: '上传中'
  382. })
  383. })
  384. for (let i = 0; i < lists.length; i++) {
  385. const result = await this.uploadFilePromise(lists[i].url)
  386. let item = this[`fileList${event.name}`][fileListLen]
  387. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  388. status: 'success',
  389. sort: this.fileList1.length,
  390. fileName: JSON.parse(result).data.originalName,
  391. url: JSON.parse(result).data.link
  392. }))
  393. fileListLen++
  394. }
  395. },
  396. uploadFilePromise(url) {
  397. return new Promise((resolve, reject) => {
  398. let a = uni.uploadFile({
  399. url: http.config.baseURL +
  400. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  401. filePath: url,
  402. name: 'file',
  403. formData: {
  404. user: 'test'
  405. },
  406. header: {
  407. // 客户端认证参数
  408. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  409. clientSecret),
  410. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  411. },
  412. success: (res) => {
  413. setTimeout(() => {
  414. resolve(res.data)
  415. }, 1000)
  416. }
  417. });
  418. })
  419. },
  420. // 删除图片
  421. deletePic(event) {
  422. let this_ = this
  423. uni.showModal({
  424. title: '提示',
  425. content: '是否确认删除',
  426. success: function(rest) {
  427. if (rest.confirm == true) {
  428. if (this_[`fileList${event.name}`][event.index].id) {
  429. removeFile({
  430. ids: this_[`fileList${event.name}`][event.index].id
  431. }).then(res => {
  432. uni.showToast({
  433. icon: "none",
  434. title: '删除成功',
  435. mask: true
  436. });
  437. this_[`fileList${event.name}`].splice(event.index, 1)
  438. })
  439. } else {
  440. uni.showToast({
  441. icon: "none",
  442. title: '删除成功',
  443. mask: true
  444. });
  445. this_[`fileList${event.name}`].splice(event.index, 1)
  446. }
  447. }
  448. }
  449. })
  450. }
  451. }
  452. }
  453. </script>
  454. <style lang="scss" scoped>
  455. .contentBox {
  456. width: 96%;
  457. margin: 0rpx auto;
  458. background-color: #FFFFFF;
  459. border-radius: 20rpx;
  460. /* box-shadow: 0 5rpx 14rpx 0 rgba(101, 176, 249, 0.42); */
  461. padding-top: -10rpx;
  462. padding-bottom: 10rpx;
  463. }
  464. .textBox {
  465. padding: 0 0px;
  466. display: flex;
  467. justify-content: space-between;
  468. font-size: 24rpx;
  469. margin-bottom: 10rpx;
  470. }
  471. ::v-deep .u-cell__body {
  472. padding: 20rpx 10rpx;
  473. }
  474. </style>