queryPart.vue 9.0 KB

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