queryPart.vue 9.9 KB

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