chooseBillModal.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <a-drawer
  3. title="全部单据"
  4. placement="right"
  5. class="chooseBillModal-new-modal jg-page-wrap"
  6. :visible="isShow"
  7. @close="isShow=false"
  8. width="70%"
  9. :get-container="false"
  10. :wrap-style="{ position: 'absolute' }">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <!-- 搜索条件 -->
  13. <div class="table-page-search-wrapper">
  14. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  15. <a-row :gutter="15">
  16. <a-col :md="7" :sm="24">
  17. <a-form-item label="单据号">
  18. <a-input id="chooseBillModal-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入单据号"/>
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="7" :sm="24">
  22. <a-form-item label="单据类型">
  23. <v-select
  24. v-model="queryParam.bizType"
  25. ref="bizType"
  26. id="chooseBillModal-bizType"
  27. code="SETTLE_BIZ_TYPE"
  28. placeholder="请选择单据类型"
  29. allowClear></v-select>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="10" :sm="24">
  33. <a-form-item label="关联单据创建时间">
  34. <rangeDate id="chooseBillModal-createDate" ref="createDate" @change="createDateChange" />
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="7" :sm="24">
  38. <a-form-item label="审核时间">
  39. <rangeDate id="chooseBillModal-auditDate" ref="rangeDate" @change="dateChange" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :md="8" :sm="24">
  43. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chooseBillModal-refresh">查询</a-button>
  44. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="chooseBillModal-reset">重置</a-button>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <div class="btn-cont">
  50. <a-button type="primary" id="chooseBillModal-modal-save" @click="handleSave">批量添加</a-button>
  51. <a-button
  52. v-if="nowChoose.length"
  53. type="primary"
  54. ghost
  55. style="margin-left: 15px;"
  56. id="chooseBillModal-modal-reSel"
  57. @click="handleReSel">重新选择</a-button>
  58. <span v-if="totalNums" style="margin-left: 15px;">已选{{ totalNums }}项</span>
  59. </div>
  60. <!-- 列表 -->
  61. <s-table
  62. class="sTable"
  63. ref="table"
  64. size="small"
  65. :rowKey="(record) => record.id"
  66. :row-selection="{columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.checked } })}"
  67. @rowSelection="rowSelectionFun"
  68. :columns="columns"
  69. :data="loadData"
  70. :showPagination="false"
  71. :scroll="{ y: 400 }"
  72. :defaultLoadData="false"
  73. bordered>
  74. </s-table>
  75. </a-spin>
  76. </a-drawer>
  77. </template>
  78. <script>
  79. import { commonMixin } from '@/utils/mixin'
  80. import { STable, VSelect } from '@/components'
  81. import rangeDate from '@/views/common/rangeDate.vue'
  82. import { settleInfoAllList } from '@/api/settle'
  83. export default {
  84. name: 'ChooseBillModal',
  85. components: { STable, VSelect, rangeDate },
  86. mixins: [commonMixin],
  87. props: {
  88. openModal: { // 弹框显示状态
  89. type: Boolean,
  90. default: false
  91. },
  92. nowChoose: { // 已选数据
  93. type: Array,
  94. default: () => {
  95. return []
  96. }
  97. },
  98. settleClientSn: { // 结算账户sn
  99. type: String,
  100. default: ''
  101. },
  102. settleClientType: { // 结算账户类型
  103. type: String,
  104. default: ''
  105. }
  106. },
  107. computed: {
  108. // 已选总记录数
  109. totalNums () {
  110. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRows && this.rowSelectionInfo.selectedRows.length
  111. }
  112. },
  113. data () {
  114. const _this = this
  115. return {
  116. spinning: false,
  117. isShow: this.openModal, // 是否打开弹框
  118. disabled: false,
  119. queryParam: {
  120. auditBeginDate: '', // 审核开始时间
  121. auditEndDate: '', // 审核结束时间
  122. bizNo: '', // 单据号
  123. bizType: undefined, // 单据类型
  124. bizCreateBeginDate: undefined, // 创建开始时间
  125. bizCreateEndDate: undefined // 创建结束时间
  126. },
  127. allData: [], // 全部单据数据
  128. // 表头
  129. columns: [
  130. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  131. { title: '单据号', dataIndex: 'bizNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '关联单据创建时间', dataIndex: 'bizCreateDate', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '审核时间', dataIndex: 'auditTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  135. { title: '总款数', dataIndex: 'bizTotalCategory', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '总数量', dataIndex: 'bizTotalQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '金额', dataIndex: 'totalAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  138. { title: '余额', dataIndex: 'unsettleAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  139. { title: '状态', dataIndex: 'checked', width: '6%', align: 'center', customRender: function (text) { return text ? '已选' : '--' } }
  140. ],
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. this.disabled = true
  144. this.spinning = true
  145. const _this = this
  146. return settleInfoAllList(Object.assign(this.queryParam, { settleClientType: this.settleClientType, settleClientSn: this.settleClientSn, notEqZero: 1 })).then(res => {
  147. let data
  148. if (res.status == 200) {
  149. data = res.data
  150. for (var i = 0; i < data.length; i++) {
  151. data[i].no = i + 1
  152. data[i].settleAmount = data[i].unsettleAmount
  153. const has = _this.nowChoose.find(item => item.id == data[i].id)
  154. data[i].checked = !!has
  155. }
  156. this.disabled = false
  157. }
  158. this.spinning = false
  159. return data
  160. })
  161. },
  162. rowSelectionInfo: null // 已选数据
  163. }
  164. },
  165. methods: {
  166. // 表格选中项
  167. rowSelectionFun (obj) {
  168. this.rowSelectionInfo = obj || null
  169. },
  170. // 重新选择
  171. handleReSel () {
  172. this.$emit('ok', [])
  173. this.resetSearchForm()
  174. },
  175. // 关联单据创建时间
  176. createDateChange (date) {
  177. this.queryParam.bizCreateBeginDate = date[0]
  178. this.queryParam.bizCreateEndDate = date[1]
  179. },
  180. // 审核时间 change
  181. dateChange (date) {
  182. this.queryParam.auditBeginDate = date[0]
  183. this.queryParam.auditEndDate = date[1]
  184. },
  185. // 确定
  186. handleSave () {
  187. if (this.totalNums) {
  188. this.$emit('ok', this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
  189. this.resetSearchForm()
  190. } else {
  191. this.$message.info('请选择单据')
  192. }
  193. },
  194. // 重置
  195. resetSearchForm () {
  196. this.$refs.rangeDate.resetDate()
  197. this.$refs.createDate.resetDate()
  198. this.queryParam.auditBeginDate = ''
  199. this.queryParam.auditEndDate = ''
  200. this.queryParam.bizCreateBeginDate = ''
  201. this.queryParam.bizCreateEndDate = ''
  202. this.queryParam.bizNo = ''
  203. this.queryParam.bizType = undefined
  204. this.$refs.table.refresh(true)
  205. this.$refs.table.clearSelected()
  206. }
  207. },
  208. watch: {
  209. // 父页面传过来的弹框状态
  210. openModal (newValue, oldValue) {
  211. this.isShow = newValue
  212. },
  213. // 重定义的弹框状态
  214. isShow (newValue, oldValue) {
  215. const _this = this
  216. if (!newValue) {
  217. _this.$emit('close')
  218. // 重置
  219. _this.$refs.table.clearSelected() // 清空表格选中项
  220. _this.selectedRowKeys = []
  221. _this.selectedRows = []
  222. _this.resetSearchForm()
  223. } else {
  224. setTimeout(() => {
  225. _this.$refs.table.refresh(true)
  226. }, 200)
  227. }
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="less">
  233. .chooseBillModal-new-modal{
  234. .btn-cont {
  235. margin: 0 0 10px 0;
  236. text-align: left;
  237. }
  238. }
  239. </style>