queryPart.vue 10 KB

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