edit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div class="salesReturnEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack">
  8. <a-icon type="left" />
  9. 返回列表
  10. </a>
  11. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.verifyAccountBillNo }}</span>
  12. <span style="margin: 0 10px;color: #666;">客户名称:{{ detailData && detailData.dealerName }}</span>
  13. <a-button type="link" size="small" class="button-default" @click.stop="handleEditBase" >
  14. <a-icon type="edit" /> 编辑备注
  15. </a-button>
  16. </template>
  17. </a-page-header>
  18. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  19. <queryPart
  20. ref="partQuery"
  21. :newLoading="isInster"
  22. :addMoreLoading="addMoreLoading"
  23. :itemSn="verifyAccountBillSn"
  24. :dealerSn="dealerSn"
  25. @add="saveProduct"
  26. @bachAdd="saveMoreProduct"></queryPart>
  27. </a-card>
  28. <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
  29. <a-alert style="margin-bottom: 10px;" type="info" v-if="countData">
  30. <div slot="message" class="total-bar">
  31. <div>
  32. <span>余额:{{ countData && (countData.bizAmount || countData.bizAmount == 0) ? toThousands(countData.bizAmount) : '--' }};</span>
  33. <span>借方:{{ countData && (countData.borrowAmount || countData.borrowAmount == 0) ? toThousands(countData.borrowAmount) : '--' }};</span>
  34. <span>贷方:{{ countData && (countData.loanAmount || countData.loanAmount == 0) ? toThousands(countData.loanAmount*-1) : '--' }};</span>
  35. </div>
  36. </div>
  37. </a-alert>
  38. <div class="table-page-search-wrapper" style="display:flex;align-items: center;justify-content: space-between;">
  39. <div style="flex-grow:1;">
  40. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  41. <a-row :gutter="15">
  42. <a-col :md="6" :sm="24">
  43. <a-form-item label="时间">
  44. <rangeDate id="accountStatement-rangeDate" ref="rangeDate" :value="creatDate" @change="dateChange" />
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="4" :sm="24">
  48. <a-form-item label="业务单号">
  49. <a-input id="accountStatement-bizNo" v-model.trim="productForm.bizNo" allowClear placeholder="请输入业务单号" />
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="4" :sm="24">
  53. <a-form-item label="借贷类型">
  54. <v-select
  55. v-model="productForm.changeType"
  56. ref="changeType1"
  57. id="accountStatement-changeType1"
  58. code="VERIFY_ACCOUNT_CHANGE_TYPE"
  59. placeholder="请选择借贷类型"
  60. allowClear></v-select>
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="4" :sm="24">
  64. <a-form-item label="业务类型">
  65. <v-select
  66. v-model="productForm.bizType"
  67. ref="bizType1"
  68. id="accountStatement-bizType1"
  69. code="VERIFY_ACCOUNT_BIZ_TYPE"
  70. placeholder="请选择业务类型"
  71. allowClear></v-select>
  72. </a-form-item>
  73. </a-col>
  74. <a-col :md="4" :sm="24">
  75. <a-button id="accountStatement-2-search" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  76. <a-button id="accountStatement-2-restForm" style="margin-left: 5px" @click="resetSearchForm">重置</a-button>
  77. </a-col>
  78. </a-row>
  79. </a-form>
  80. </div>
  81. <div>
  82. <a-button id="accountStatement-tzhang" style="margin-bottom: 10px;" type="primary" @click="handleAdd">调账</a-button>
  83. </div>
  84. </div>
  85. <!-- 已选配件列表 -->
  86. <s-table
  87. class="sTable"
  88. ref="table"
  89. size="small"
  90. :rowKey="(record) => record.id"
  91. :columns="columns"
  92. :data="loadData"
  93. :defaultLoadData="false"
  94. :scroll="{ y: 300 }"
  95. bordered>
  96. <!-- 备注 -->
  97. <template slot="remark" slot-scope="text, record">
  98. <div @dblclick.stop>
  99. <a-input
  100. size="small"
  101. v-model="record.remarks"
  102. :disabled="record.editFlag==0"
  103. @blur="changeRemarks(record)"
  104. style="width: 100%;"
  105. placeholder="请输入备注"/>
  106. </div>
  107. </template>
  108. <!-- 操作 -->
  109. <template slot="action" slot-scope="text, record">
  110. <a-button
  111. size="small"
  112. type="link"
  113. :loading="delLoading"
  114. class="button-error"
  115. @click="handleDel(record)"
  116. id="salesReturn-Del">删除</a-button>
  117. </template>
  118. </s-table>
  119. </a-card>
  120. </a-spin>
  121. <div class="affix-cont">
  122. <a-button
  123. size="large"
  124. style="padding: 0 60px;"
  125. :disabled="spinning"
  126. type="primary"
  127. class="button-primary"
  128. @click="handleSubmit"
  129. id="salesReturn-handleSubmit">提交</a-button>
  130. </div>
  131. <!-- 编辑基础信息弹窗 -->
  132. <baseModal v-drag :show="openModal" @cancel="openModal=false" :itemSn="verifyAccountBillSn" @refashData="getBasicsData"></baseModal>
  133. <!-- 基础信息 -->
  134. <baseTzModal
  135. v-drag
  136. :show="baseModal"
  137. type="1"
  138. :itemSn="verifyAccountBillSn"
  139. @cancel="baseModal=false"
  140. @ok="hanldAudit"></baseTzModal>
  141. </div>
  142. </template>
  143. <script>
  144. import { commonMixin } from '@/utils/mixin'
  145. import { STable, VSelect } from '@/components'
  146. import queryPart from './queryPart.vue'
  147. import baseModal from './baseModal.vue'
  148. import baseTzModal from '../manualEntryForm/baseModal.vue'
  149. import rangeDate from '@/views/common/rangeDate.vue'
  150. import {
  151. verifyAcountBillDetailList,
  152. verifyAcountBillDetailQueryCount,
  153. verifyAcountBillDetailDel,
  154. verifyAcountBillDetailSave,
  155. verifyAcountBillDetailModify,
  156. verifyAcountBillSubmit,
  157. verifyAcountBillSubmitCheck,
  158. verifyAcountBillDetail
  159. } from '@/api/verifyAccount'
  160. export default {
  161. name: 'AccountStatementEdit',
  162. mixins: [commonMixin],
  163. components: {
  164. STable,
  165. VSelect,
  166. queryPart,
  167. baseModal,
  168. rangeDate,
  169. baseTzModal
  170. },
  171. data () {
  172. return {
  173. spinning: false,
  174. isInster: false, // 是否正在添加产品
  175. baseModal: false,
  176. openDepartUserModal: false,
  177. delLoading: false,
  178. productForm: {
  179. beginDate: '',
  180. endDate: '',
  181. bizNo: '',
  182. changeType: undefined,
  183. bizType: undefined
  184. },
  185. creatDate: [],
  186. chooseList: [],
  187. // 加载数据方法 必须为 Promise 对象
  188. loadData: parameter => {
  189. const params = {
  190. ...parameter,
  191. verifyAccountBillSn: this.verifyAccountBillSn,
  192. verifyAccountBillNo: this.detailData.verifyAccountBillNo,
  193. ...this.productForm
  194. }
  195. return verifyAcountBillDetailList(params).then(res => {
  196. let data
  197. if (res.status == 200) {
  198. data = res.data
  199. const no = (data.pageNo - 1) * data.pageSize
  200. for (var i = 0; i < data.list.length; i++) {
  201. data.list[i].no = no + i + 1
  202. if (data.list[i].bizDate) {
  203. const dates = data.list[i].bizDate.split('-')
  204. data.list[i].year = dates[0]
  205. data.list[i].month = dates[1]
  206. data.list[i].day = dates[2].split(' ')[0]
  207. }
  208. // 正为借方, 负数为贷方
  209. if (data.list[i].bizAmount > 0) {
  210. data.list[i].debitAmount = data.list[i].bizAmount
  211. } else {
  212. data.list[i].creditorAmount = data.list[i].bizAmount * -1
  213. }
  214. }
  215. }
  216. this.getStatisticsData(params)
  217. this.chooseList = data.list
  218. return data
  219. })
  220. },
  221. openModal: false, // 修改信息弹窗
  222. countData: null, // 统计明细
  223. detailData: null, // 基础信息数据
  224. addMoreLoading: false, // 批量添加动画
  225. verifyAccountBillSn: undefined, // 单据sn
  226. itemSn: null
  227. }
  228. },
  229. computed: {
  230. dealerSn () {
  231. return this.detailData ? this.detailData.dealerSn : ''
  232. },
  233. columns () {
  234. const _this = this
  235. const arr = [
  236. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  237. { title: '年', dataIndex: 'year', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '月', dataIndex: 'month', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  239. { title: '日', dataIndex: 'day', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '业务单号', dataIndex: 'bizNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  241. { title: '业务类型', dataIndex: 'bizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  242. { title: '业务状态', dataIndex: 'bizStatusDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  243. { title: '费用/调拨类型', dataIndex: 'expenseAllocateType', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  244. { title: '摘要', dataIndex: 'digestInfo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '客诉索赔编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  246. { title: '借方', dataIndex: 'debitAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  247. { title: '贷方', dataIndex: 'creditorAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
  248. { title: '备注', scopedSlots: { customRender: 'remark' }, width: '15%', align: 'center' },
  249. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  250. ]
  251. return arr
  252. }
  253. },
  254. methods: {
  255. // 编辑基础信息
  256. handleEditBase () {
  257. this.openModal = true
  258. },
  259. // 返回列表
  260. handleBack () {
  261. this.$router.push({ name: `accountStatementList` })
  262. },
  263. // 创建时间 change
  264. dateChange (date) {
  265. this.productForm.beginDate = date[0] ? date[0] : ''
  266. this.productForm.endDate = date[1] ? date[1] : ''
  267. },
  268. // 调账
  269. handleAdd () {
  270. this.itemSn = null
  271. this.baseModal = true
  272. },
  273. // 打开审核提交弹框
  274. hanldAudit (data) {
  275. this.$message.success('提交成功')
  276. this.resetTable(false)
  277. },
  278. // 删除所选产品
  279. handleDel (row) {
  280. const _this = this
  281. this.$confirm({
  282. title: '提示',
  283. content: '确认要删除吗?',
  284. centered: true,
  285. closable: true,
  286. onOk () {
  287. _this.delDetail([row.detailSn])
  288. }
  289. })
  290. },
  291. delDetail (snList) {
  292. const _this = this
  293. _this.delLoading = true
  294. _this.spinning = true
  295. verifyAcountBillDetailDel({ verifyAccountBillSn: _this.verifyAccountBillSn, detailSnList: snList })
  296. .then(res => {
  297. if (res.status == 200) {
  298. _this.resetTable(false)
  299. _this.getChooseList()
  300. _this.$refs.partQuery.clearSelected()
  301. }
  302. _this.$message.info(res.message)
  303. _this.delLoading = false
  304. _this.spinning = false
  305. })
  306. .catch(err => {
  307. _this.delLoading = false
  308. })
  309. },
  310. // 刷新已选表格
  311. resetTable (flag) {
  312. this.$refs.table.refresh(flag)
  313. },
  314. // 重置
  315. resetSearchForm (flag) {
  316. this.productForm.beginDate = ''
  317. this.productForm.endDate = ''
  318. this.productForm.bizNo = ''
  319. this.productForm.changeType = undefined
  320. this.productForm.bizType = undefined
  321. this.productForm.bizStatus = undefined
  322. this.creatDate = []
  323. this.$refs.rangeDate.resetDate(this.creatDate)
  324. this.$refs.table.refresh(!!flag)
  325. },
  326. // 修改备注
  327. changeRemarks (record) {
  328. this.spinning = true
  329. verifyAcountBillDetailModify({ id: record.id, remarks: record.remarks }).then(res => {
  330. this.spinning = false
  331. })
  332. },
  333. // 单个添加单据
  334. saveProduct (row) {
  335. if (this.isInster) {
  336. // 防止多次添加产品
  337. return
  338. }
  339. this.isInster = true
  340. const paramsData = {
  341. verifyAccountBillSn: this.detailData.verifyAccountBillSn,
  342. verifyAccountBillNo: this.detailData.verifyAccountBillNo,
  343. verifyAccountBizSn: this.detailData.verifyAccountBizSn,
  344. detailList: [row]
  345. }
  346. this.saveMore(paramsData)
  347. },
  348. // 批量添加
  349. saveMoreProduct (data) {
  350. if (this.addMoreLoading) {
  351. // 防止多次添加产品
  352. return
  353. }
  354. this.addMoreLoading = true
  355. this.saveMore({
  356. verifyAccountBillSn: this.detailData.verifyAccountBillSn,
  357. verifyAccountBillNo: this.detailData.verifyAccountBillNo,
  358. verifyAccountBizSn: this.detailData.verifyAccountBizSn,
  359. detailList: data
  360. })
  361. },
  362. // 添加
  363. saveMore (params) {
  364. this.spinning = true
  365. verifyAcountBillDetailSave(params)
  366. .then(res => {
  367. if (res.status == 200) {
  368. this.getChooseList()
  369. this.$refs.table.refresh(true)
  370. this.$refs.partQuery.clearSelected()
  371. }
  372. this.isInster = false
  373. this.spinning = false
  374. this.addMoreLoading = false
  375. })
  376. .catch(err => {
  377. this.isInster = false
  378. this.addMoreLoading = false
  379. this.spinning = false
  380. })
  381. },
  382. // 提交
  383. async handleSubmit () {
  384. this.spinning = true
  385. const ret = await verifyAcountBillSubmitCheck({ sn: this.verifyAccountBillSn })
  386. this.spinning = false
  387. const noList = ret.data.length ? ret.data.map(item => item.bizNo) : []
  388. const snList = ret.data.length ? ret.data.map(item => item.detailSn) : []
  389. // 通过校验提交
  390. if (noList.length == 0) {
  391. this.spinning = true
  392. verifyAcountBillSubmit({ sn: this.verifyAccountBillSn }).then(res => {
  393. if (res.status == 200) {
  394. this.handleBack()
  395. this.$message.success(res.message)
  396. }
  397. this.spinning = false
  398. })
  399. } else {
  400. // 提示不能参与的单子
  401. const _this = this
  402. this.$confirm({
  403. title: '提示(' + _this.detailData.dealerName + ')',
  404. content: <div style="font-size:14px;"><div>{noList.toString()}不能参与对单,</div><div>点击【确定】后自动移除上述单据</div></div>,
  405. centered: true,
  406. closable: true,
  407. onOk () {
  408. _this.delDetail(snList)
  409. }
  410. })
  411. }
  412. },
  413. getChooseList () {
  414. this.$refs.partQuery.pageInit()
  415. },
  416. // 获取页面统计数据
  417. getStatisticsData (params) {
  418. verifyAcountBillDetailQueryCount(params).then(res => {
  419. this.countData = res.data
  420. })
  421. },
  422. // 获取基础信息
  423. getBasicsData (flag) {
  424. const _this = this
  425. verifyAcountBillDetail({ sn: this.verifyAccountBillSn }).then(res => {
  426. _this.detailData = res.data
  427. if (!flag) {
  428. _this.$nextTick(() => {
  429. _this.resetSearchForm(true)
  430. _this.getChooseList()
  431. })
  432. }
  433. })
  434. },
  435. pageInit () {
  436. this.verifyAccountBillSn = this.$route.params.sn
  437. this.getBasicsData()
  438. }
  439. },
  440. mounted () {
  441. if (!this.$store.state.app.isNewTab) {
  442. // 页签刷新时调用
  443. this.pageInit()
  444. }
  445. },
  446. activated () {
  447. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  448. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  449. this.pageInit()
  450. }
  451. },
  452. beforeRouteEnter (to, from, next) {
  453. next(vm => {})
  454. }
  455. }
  456. </script>
  457. <style lang="less">
  458. .salesReturnEdit-wrap {
  459. position: relative;
  460. height: 100%;
  461. padding-bottom: 51px;
  462. box-sizing: border-box;
  463. > .ant-spin-nested-loading {
  464. overflow-y: scroll;
  465. height: 100%;
  466. }
  467. .salesReturnEdit-cont {
  468. margin-top: 6px;
  469. .ant-divider-horizontal {
  470. margin: 10px 0 24px;
  471. }
  472. .total-bar {
  473. display: flex;
  474. align-items: center;
  475. justify-content: space-between;
  476. > div {
  477. &:last-child {
  478. display: flex;
  479. align-items: center;
  480. justify-content: space-between;
  481. > div {
  482. padding: 0 10px;
  483. }
  484. }
  485. }
  486. }
  487. }
  488. }
  489. </style>