queryPart.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="salesReturnList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24" v-if="grabFlag == 1">
  8. <a-form-item label="销售单号">
  9. <a-input id="salesReturnList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="salesReturnList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品名称">
  19. <a-input id="salesReturnList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  23. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="salesReturnList-refresh">查询</a-button>
  24. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesReturnList-reset">重置</a-button>
  25. </a-col>
  26. </a-row>
  27. </a-form>
  28. </div>
  29. <!-- 列表 -->
  30. <s-table
  31. class="sTable"
  32. ref="table"
  33. size="small"
  34. :rowKey="(record) => record.id"
  35. :columns="columns"
  36. :data="loadData"
  37. :customRow="handleClickRow"
  38. :rowClassName="(record, index) => (grabFlag == '1'&&record.refundableQty==0) ? 'redBg-row':''"
  39. :defaultLoadData="false"
  40. :scroll="{ x: grabFlag == '1' ? 930 : 710, y: 300 }"
  41. bordered>
  42. <!-- 本次退货数量 -->
  43. <template slot="qty" slot-scope="text, record">
  44. <div @dblclick.stop>
  45. <a-input-number
  46. size="small"
  47. v-model="record.qty"
  48. :precision="0"
  49. :min="0"
  50. :max="999999"
  51. placeholder="请输入" />
  52. </div>
  53. </template>
  54. <span slot="customTitle">
  55. 操作
  56. <a-popover>
  57. <template slot="content">
  58. 双击列表配件可快速选中添加
  59. </template>
  60. <a-icon type="question-circle" theme="twoTone" />
  61. </a-popover>
  62. </span>
  63. <!-- 操作 -->
  64. <template slot="action" slot-scope="text, record">
  65. <a-button
  66. size="small"
  67. type="primary"
  68. class="button-info"
  69. :loading="newLoading"
  70. :disabled="grabFlag == '1'&&record.refundableQty==0"
  71. @click="handleAdd(record)"
  72. >添加</a-button>
  73. </template>
  74. </s-table>
  75. </div>
  76. </template>
  77. <script>
  78. import { salesQueryByReturn } from '@/api/salesReturn'
  79. import { queryStockProductPage } from '@/api/stock'
  80. import { STable, VSelect } from '@/components'
  81. export default {
  82. name: 'QueryPart',
  83. components: { STable, VSelect },
  84. props: {
  85. newLoading: Boolean
  86. },
  87. data () {
  88. return {
  89. buyerSn: '',
  90. grabFlag: '',
  91. priceType: '',
  92. queryParam: { // 查询条件
  93. salesBillNo: '', // 销售单号
  94. productName: '', // 产品名称
  95. productCode: '' // 产品编码
  96. },
  97. disabled: false, // 查询、重置按钮是否可操作
  98. columns: [],
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. // 抓单时
  103. if (this.grabFlag == 1) {
  104. this.queryParam.buyerSn = this.buyerSn
  105. }
  106. // 不抓单
  107. if (this.grabFlag == 0) {
  108. this.queryParam.dealerSn = this.buyerSn
  109. }
  110. const fun = [queryStockProductPage, salesQueryByReturn]
  111. return fun[this.grabFlag](Object.assign(parameter, this.queryParam, { onlineFalg: '1' })).then(res => {
  112. const data = res.data
  113. const no = (data.pageNo - 1) * data.pageSize
  114. for (var i = 0; i < data.list.length; i++) {
  115. data.list[i].no = no + i + 1
  116. data.list[i].qty = 1
  117. }
  118. this.disabled = false
  119. return data
  120. })
  121. }
  122. }
  123. },
  124. mounted () {
  125. // 抓单
  126. if (this.grabFlag == 1) {
  127. this.columns = [
  128. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  129. { title: '销售单号', dataIndex: 'salesBillNo', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '售价', dataIndex: 'price', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '剩余可退数量', dataIndex: 'refundableQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  134. { title: '本次退货数量', dataIndex: 'qty', width: 100, align: 'center', scopedSlots: { customRender: 'qty' } },
  135. { title: '采购价', dataIndex: 'showCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '单位', dataIndex: 'productEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  137. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }]
  138. } else {
  139. this.columns = [
  140. { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
  141. { title: '产品编码', dataIndex: 'productCode', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '产品名称', dataIndex: 'productName', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '当前售价', dataIndex: 'productPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '退货数量', dataIndex: 'qty', width: 100, align: 'center', scopedSlots: { customRender: 'qty' } },
  145. { title: '采购价', dataIndex: 'lastStockCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  146. { title: '单位', dataIndex: 'productUnit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  147. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 80, align: 'center' }
  148. ]
  149. }
  150. },
  151. methods: {
  152. // 双击列表选择配件
  153. handleClickRow (record) {
  154. const _this = this
  155. return {
  156. on: {
  157. dblclick: (event) => {
  158. if (_this.grabFlag == '1' && record.refundableQty == 0) {
  159. _this.$message.info('该产品暂时不能添加')
  160. } else {
  161. event.stopPropagation()
  162. _this.$emit('add', record)
  163. }
  164. }
  165. }
  166. }
  167. },
  168. // 重置
  169. resetSearchForm () {
  170. this.queryParam.salesBillNo = ''
  171. this.queryParam.productName = ''
  172. this.queryParam.productCode = ''
  173. this.$refs.table.refresh(true)
  174. },
  175. pageInit (buyerSn, grabFlag) {
  176. this.buyerSn = buyerSn
  177. this.grabFlag = grabFlag
  178. this.resetSearchForm()
  179. },
  180. // 选择配件
  181. handleAdd (row) {
  182. this.$emit('add', row)
  183. },
  184. refreshData () {
  185. this.$refs.table.refresh()
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="less">
  191. .salesReturnList-wrap{
  192. .redBg-row{
  193. background-color: #f5cdc8;
  194. }
  195. }
  196. </style>