edit.vue 17 KB

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