queryPart.vue 10 KB

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