detailModal.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <a-modal
  3. centered
  4. class="collection-detail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. :title="modalTit"
  9. :bodyStyle="{padding: modalTit?'25px 32px 20px':'50px 32px 15px'}"
  10. @cancle="isShow=false"
  11. width="80%">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <div class="common-main">
  14. <div class="toolsBar">
  15. <div v-if="handlePlData.length">{{ handlePlData[0].settleClientName }},共 {{ handlePlData && handlePlData.length }} 个备货单,合计 {{ totalAmount }} 元,已选择 2 个收款单</div>
  16. <a-button type="primary" class="button-primary" @click="handleCommonOk">{{ okText }}</a-button>
  17. </div>
  18. <div>
  19. <a-table :columns="columns" :scroll="{ y: 400 }" :pagination="false" :data-source="chooseData" bordered>
  20. <!-- 收款单号 -->
  21. <template slot="bookNo" slot-scope="text, record">
  22. <span class="link-bule">{{ record.bookNo }}</span>
  23. </template>
  24. <!-- 操作 -->
  25. <template slot="action" slot-scope="text, record">
  26. <a-button
  27. size="small"
  28. type="link"
  29. class="button-error"
  30. @click="handleDel(record)"
  31. >
  32. 删除
  33. </a-button>
  34. </template>
  35. </a-table>
  36. </div>
  37. </div>
  38. <a-divider>请选择收款单</a-divider>
  39. <div class="common-main">
  40. <!-- 搜索条件 -->
  41. <div ref="tableSearch" class="table-page-search-wrapper">
  42. <a-form layout="inline">
  43. <a-row :gutter="15">
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="收款单号">
  46. <a-input v-model.trim="queryParam.bookNo" allowClear placeholder="请输入收款单号"/>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="财务收款事由">
  51. <a-input v-model.trim="queryParam.bookReason" allowClear placeholder="请输入财务收款事由"/>
  52. </a-form-item>
  53. </a-col>
  54. <a-col :md="6" :sm="24">
  55. <a-form-item label="申请人">
  56. <employee style="width: 100%;" placeholder="请选择申请人" v-model="queryParam.applyPersonSn"></employee>
  57. </a-form-item>
  58. </a-col>
  59. <a-col :md="6" :sm="24">
  60. <span class="table-page-search-submitButtons">
  61. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  62. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  63. </span>
  64. </a-col>
  65. </a-row>
  66. </a-form>
  67. </div>
  68. <!-- 表格数据 -->
  69. <s-table
  70. class="sTable"
  71. ref="table"
  72. size="small"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ y: 400 }"
  77. bordered>
  78. <!-- 单号 -->
  79. <template slot="bookNo" slot-scope="text, record">
  80. <span class="link-bule">{{ record.bookNo }}</span>
  81. </template>
  82. <!-- 操作 -->
  83. <template slot="action" slot-scope="text, record">
  84. <a-button
  85. size="small"
  86. type="link"
  87. class="button-warning"
  88. v-if="!record.checked"
  89. @click="handleChoose(record)"
  90. >选择</a-button>
  91. <span style="color:green;" v-else>已选</span>
  92. </template>
  93. </s-table>
  94. </div>
  95. </a-spin>
  96. </a-modal>
  97. </template>
  98. <script>
  99. import { STable, VSelect } from '@/components'
  100. import { financeBookQueryPage } from '@/api/financeBook.js'
  101. import employee from '../../expenseManagement/expenseReimbursement/employee.js'
  102. import { settleReceiptBookBatch } from '@/api/settleReceipt'
  103. export default {
  104. name: 'CommonModal',
  105. components: { STable, VSelect, employee },
  106. props: {
  107. openModal: { // 弹框显示状态
  108. type: Boolean,
  109. default: false
  110. },
  111. modalTit: { // 弹框标题
  112. type: String,
  113. default: null
  114. },
  115. okText: { // 确定 按钮文字
  116. type: String,
  117. default: '确定收款'
  118. },
  119. cancelText: { // 取消 按钮文字
  120. type: String,
  121. default: '取消'
  122. },
  123. isCancel: { // 是否显示 取消 按钮
  124. type: Boolean,
  125. default: true
  126. }
  127. },
  128. data () {
  129. return {
  130. isShow: this.openModal, // 是否打开弹框
  131. disabled: false,
  132. spinning: false,
  133. handlePlData: [],
  134. queryParam: {
  135. bookNo: '',
  136. bookReason: '',
  137. applyPersonSn: undefined,
  138. status: 'AUDIT_PASS'
  139. },
  140. chooseData: [],
  141. columns: [
  142. { title: '序号', dataIndex: 'no', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '收款单号', scopedSlots: { customRender: 'bookNo' }, width: '8%', align: 'center' },
  144. { title: '申请人', dataIndex: 'applyPersonName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  145. { title: '财务收款事由', dataIndex: 'bookReason', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  146. { title: '订单总金额', dataIndex: 'orderTotalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '收款总金额', dataIndex: 'receiptTotalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  148. { title: '使用授信总金额', dataIndex: 'useTotalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  149. { title: '授信还款总金额', dataIndex: 'payTotalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '余款抵扣总金额', dataIndex: 'balanceTotalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '审核时间', dataIndex: 'auditDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  152. { title: '状态', dataIndex: 'statusDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  154. ],
  155. orginData: [],
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. this.disabled = true
  159. this.spinning = true
  160. return financeBookQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
  161. let data
  162. if (res.status == 200) {
  163. data = res.data
  164. const no = (data.pageNo - 1) * data.pageSize
  165. for (var i = 0; i < data.list.length; i++) {
  166. data.list[i].no = no + i + 1
  167. const index = this.chooseData.findIndex(item => data.list[i].bookSn == item.bookSn)
  168. data.list[i].checked = index >= 0
  169. }
  170. this.disabled = false
  171. }
  172. this.spinning = false
  173. this.orginData = data.list
  174. return data
  175. })
  176. },
  177. snList: []
  178. }
  179. },
  180. computed: {
  181. totalAmount () {
  182. let ret = 0
  183. this.handlePlData.map(item => {
  184. ret = ret + item.totalAmount
  185. })
  186. return ret.toFixed(2)
  187. }
  188. },
  189. methods: {
  190. setData (data, snList) {
  191. this.handlePlData = data
  192. this.snList = snList
  193. },
  194. // 删除
  195. handleDel (row) {
  196. const i = this.chooseData.findIndex(item => row.bookSn == item.bookSn)
  197. const oi = this.orginData.findIndex(item => row.bookSn == item.bookSn)
  198. this.chooseData.splice(i, 1)
  199. if (oi >= 0) {
  200. this.orginData[oi].checked = false
  201. }
  202. },
  203. // 选择
  204. handleChoose (row) {
  205. row.checked = true
  206. this.chooseData.push(row)
  207. },
  208. // 获取sn
  209. // 确定收款
  210. handleCommonOk () {
  211. const snList = this.snList
  212. const bookSnList = []
  213. this.chooseData.map(item => {
  214. bookSnList.push(item.bookSn)
  215. })
  216. if (bookSnList.length) {
  217. this.spinning = true
  218. settleReceiptBookBatch({
  219. bookSnList: bookSnList,
  220. snList: snList
  221. }).then(res => {
  222. this.spinning = false
  223. if (res.status == 200) {
  224. this.$emit('ok')
  225. this.$message.info(res.message)
  226. }
  227. })
  228. } else {
  229. this.$message.info('请选择关联的财务收款单')
  230. }
  231. },
  232. // 取消
  233. handleCommonCancel () {
  234. this.$emit('cancel')
  235. this.chooseData = []
  236. },
  237. // 重置
  238. resetSearchForm () {
  239. this.queryParam = {
  240. bookNo: '',
  241. bookReason: '',
  242. applyPersonSn: undefined,
  243. status: 'AUDIT_PASS'
  244. }
  245. this.$refs.table.refresh(true)
  246. }
  247. },
  248. watch: {
  249. // 父页面传过来的弹框状态
  250. openModal (newValue, oldValue) {
  251. this.isShow = newValue
  252. },
  253. // 重定义的弹框状态
  254. isShow (newValue, oldValue) {
  255. if (!newValue) {
  256. this.handleCommonCancel()
  257. }
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="less">
  263. .collection-detail-modal{
  264. .common-main{
  265. .toolsBar{
  266. display: flex;
  267. align-items: center;
  268. margin-bottom: 10px;
  269. .ant-btn{
  270. margin-left: 30px;
  271. }
  272. }
  273. }
  274. }
  275. </style>