queryPart.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="accountStatement-query-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <div style="width:100%">
  6. <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="时间">
  10. <rangeDate id="accountStatement-query-rangeDate" ref="rangeDate" :value="creatDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="业务单号">
  15. <a-input id="accountStatement-query-bizNo" v-model.trim="queryParam.bizNo" allowClear placeholder="请输入业务单号"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="借贷类型">
  20. <v-select
  21. v-model="queryParam.changeType"
  22. ref="jdType"
  23. id="accountStatement-query-jdType"
  24. code="FINANCE_BOOK_STATE"
  25. placeholder="请选择借贷类型"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="业务类型">
  31. <v-select
  32. v-model="queryParam.bizType"
  33. ref="bizType"
  34. id="accountStatement-query-bizType"
  35. code="FINANCE_BOOK_STATE"
  36. placeholder="请选择单据类型"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="业务状态">
  42. <!-- 备货单状态,销售退货单,调拨单,费用报销单 -->
  43. <v-select
  44. v-model="queryParam.bizStatus"
  45. ref="bizStatus"
  46. id="accountStatement-query-bizStatus"
  47. :code="['DISPATCH_BILL_STATUS','SALES_RETURN_BILL_STATUS','ALLOCATE_STATUS','EXPENSE_STATE'][0]"
  48. placeholder="请选择业务状态"
  49. allowClear></v-select>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="4" :sm="24">
  53. <a-button type="primary" @click="$refs.chooseTable.refresh(true)" id="accountStatement-query-refresh">查询</a-button>
  54. <a-button style="margin-left: 5px" @click="resetSearchForm" id="accountStatement-query-reset">重置</a-button>
  55. </a-col>
  56. <a-col :md="24" :sm="24" style="margin-bottom: 10px;display: flex;align-items: center;justify-content: space-between;">
  57. <div>
  58. <a-button type="primary" style="margin-right: 5px" @click="handleBatchAdd" :loading="addMoreLoading">批量选择</a-button>
  59. <span v-if="selNums&&selNums!=0" style="margin:0 10px;">已选中{{ selNums }}项</span>
  60. </div>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </div>
  65. </div>
  66. <!-- 列表 -->
  67. <s-table
  68. class="sTable"
  69. ref="chooseTable"
  70. size="small"
  71. :rowKey="(record) => record.no"
  72. rowKeyName="no"
  73. :row-selection="{ columnWidth: 40,getCheckboxProps: record => ({ props: { disabled: record.currentStockQty == 0 || record.isCheckedFlag} }) }"
  74. @rowSelection="rowSelectionFun"
  75. :columns="columns"
  76. :data="loadData"
  77. :defaultLoadData="false"
  78. :scroll="{ y: 300 }"
  79. bordered>
  80. <!-- 备注 -->
  81. <template slot="remarks" slot-scope="text, record">
  82. <div @dblclick.stop>
  83. <a-input
  84. size="small"
  85. v-model="record.remarks"
  86. style="width: 100%;"
  87. placeholder="请输入备注"/>
  88. </div>
  89. </template>
  90. <!-- 操作 -->
  91. <template slot="action" slot-scope="text, record">
  92. <a-button
  93. size="small"
  94. type="link"
  95. class="button-info"
  96. :loading="newLoading"
  97. @click="handleAdd(record)"
  98. >选择</a-button>
  99. </template>
  100. </s-table>
  101. </div>
  102. </template>
  103. <script>
  104. import { queryDetailStockPage } from '@/api/spareParts'
  105. import { queryDetailSnListBySn } from '@/api/sparePartsReturn'
  106. import { STable, VSelect } from '@/components'
  107. import rangeDate from '@/views/common/rangeDate.vue'
  108. import { toThousands } from '@/libs/tools.js'
  109. export default {
  110. name: 'QueryPart',
  111. components: { STable, VSelect, rangeDate },
  112. props: {
  113. newLoading: Boolean,
  114. addMoreLoading: {
  115. type: Boolean,
  116. default: false
  117. }
  118. },
  119. data () {
  120. return {
  121. buyerSn: '',
  122. queryParam: { // 查询条件
  123. beginDate: '',
  124. endDate: '',
  125. bizNo: '',
  126. changeType: undefined,
  127. bizType: undefined,
  128. bizStatus: undefined
  129. },
  130. creatDate: [], // 创建时间
  131. rowSelectionInfo: null,
  132. isChecked: false,
  133. repeatList: null,
  134. warehouseSn: null,
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. return queryDetailStockPage(Object.assign(parameter, this.queryParam)).then(res => {
  138. let data
  139. if (res.status == 200) {
  140. data = res.data
  141. const no = (data.pageNo - 1) * data.pageSize
  142. for (var i = 0; i < data.list.length; i++) {
  143. data.list[i].no = no + i + 1
  144. }
  145. }
  146. return data
  147. })
  148. }
  149. }
  150. },
  151. computed: {
  152. columns () {
  153. const arr = [
  154. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  155. { title: '年', dataIndex: 'year', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '月', dataIndex: 'month', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '日', dataIndex: 'day', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '业务单号', dataIndex: 'bizNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '业务类型', dataIndex: 'bizType', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '业务状态', dataIndex: 'bizStatus', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  161. { title: '费用/调拨类型', dataIndex: 'product.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '摘要', dataIndex: 'digestInfo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '客诉索赔编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: function (text) { return (text || text == 0) ? text : '--' } },
  164. { title: '借方', dataIndex: 'debitAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') } },
  165. { title: '贷方', dataIndex: 'creditorAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? toThousands(text, 2) : '--') } },
  166. { title: '备注', scopedSlots: { customRender: 'remarks' }, width: '15%', align: 'center' },
  167. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  168. ]
  169. return arr
  170. },
  171. selNums () {
  172. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  173. }
  174. },
  175. methods: {
  176. // 创建时间 change
  177. dateChange (date) {
  178. this.queryParam.beginDate = date[0] ? date[0] : ''
  179. this.queryParam.endDate = date[1] ? date[1] : ''
  180. },
  181. // 重置
  182. resetSearchForm () {
  183. this.queryParam.bizNo = ''
  184. this.queryParam.beginDate = ''
  185. this.queryParam.endDate = ''
  186. this.queryParam.bizNo = ''
  187. this.queryParam.changeType = undefined
  188. this.queryParam.bizType = undefined
  189. this.queryParam.bizStatus = undefined
  190. this.creatDate = []
  191. this.$refs.rangeDate.resetDate(this.creatDate)
  192. this.$refs.chooseTable.refresh(true)
  193. },
  194. pageInit () {
  195. this.$refs.chooseTable.refresh()
  196. // this.$refs.chooseTable.clearSelected()
  197. },
  198. // 添加
  199. handleAdd (row) {
  200. const selectArr = this.rowSelectionInfo ? this.rowSelectionInfo.selectedRowKeys : null
  201. if (selectArr && selectArr.length > 0) {
  202. const pot = selectArr.findIndex(item => { return item == row.id })
  203. selectArr.splice(pot, 1)
  204. const index = this.rowSelectionInfo.selectedRows.findIndex(item => { return item.sparePartsDetailSn == row.sparePartsDetailSn })
  205. this.rowSelectionInfo.selectedRows.splice(index, 1)
  206. this.$nextTick(() => { // 页面渲染完成后的回调
  207. this.$refs.chooseTable.setTableSelected(selectArr, this.rowSelectionInfo.selectedRows) // 设置表格选中项
  208. })
  209. }
  210. this.$emit('add', row)
  211. },
  212. // 删除后选中长度恢复
  213. refreshLength (row) {
  214. this.$refs.chooseTable.clearSelected()
  215. },
  216. // 表格选中项
  217. rowSelectionFun (obj) {
  218. this.rowSelectionInfo = obj || null
  219. },
  220. // 批量添加
  221. handleBatchAdd () {
  222. const row = this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys
  223. if (!row || row.length == 0) {
  224. this.$message.warning('请先选择单据!')
  225. return
  226. }
  227. this.$emit('bachAdd', this.rowSelectionInfo.selectedRows)
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="less" scoped>
  233. .accountStatement-query-wrap{
  234. .redBg-row{
  235. background-color: #f5cdc8;
  236. }
  237. }
  238. /deep/.sTable input:disabled{
  239. color:gray !important;
  240. -webkit-text-fill-color:gray !important;
  241. }
  242. </style>