queryPart.vue 7.0 KB

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