queryPart.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="1"
  46. :max="999999"
  47. style="width: 100%;"
  48. placeholder="请输入" />
  49. </div>
  50. </template>
  51. <!-- 退货原因 -->
  52. <template slot="returnReason" slot-scope="text, record">
  53. <div @dblclick.stop>
  54. <returnReason v-model="record.returnReason"></returnReason>
  55. </div>
  56. </template>
  57. <span slot="customTitle">
  58. 操作
  59. <a-popover>
  60. <template slot="content">
  61. 双击列表配件可快速选中添加
  62. </template>
  63. <a-icon type="question-circle" theme="twoTone" />
  64. </a-popover>
  65. </span>
  66. <!-- 操作 -->
  67. <template slot="action" slot-scope="text, record">
  68. <a-button
  69. size="small"
  70. type="link"
  71. class="button-info"
  72. :disabled="newLoading"
  73. v-if="record.productPrice"
  74. @click="handleAdd(record)"
  75. >添加</a-button>
  76. <span v-else>--</span>
  77. </template>
  78. </s-table>
  79. </div>
  80. </template>
  81. <script>
  82. import { queryStockProductPage } from '@/api/stock'
  83. import returnReason from '@/views/common/returnReason'
  84. import { STable, VSelect } from '@/components'
  85. export default {
  86. name: 'QueryPart',
  87. components: { STable, VSelect, returnReason },
  88. props: {
  89. newLoading: Boolean,
  90. isShowPrice: {
  91. type: Boolean,
  92. default: true
  93. }
  94. },
  95. data () {
  96. return {
  97. buyerSn: '',
  98. priceType: '',
  99. queryParam: { // 查询条件
  100. productName: '', // 产品名称
  101. productCode: '' // 产品编码
  102. },
  103. disabled: false, // 查询、重置按钮是否可操作
  104. columns: [],
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. this.disabled = true
  108. this.queryParam.dealerSn = this.buyerSn
  109. return queryStockProductPage(Object.assign(parameter, this.queryParam)).then(res => {
  110. let data
  111. if (res.status == 200) {
  112. 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. }
  120. return data
  121. })
  122. }
  123. }
  124. },
  125. methods: {
  126. // 双击列表选择配件
  127. handleClickRow (record) {
  128. const _this = this
  129. return {
  130. on: {
  131. dblclick: (event) => {
  132. event.stopPropagation()
  133. if (record.productPrice) {
  134. _this.$emit('add', record)
  135. }
  136. }
  137. }
  138. }
  139. },
  140. // 重置
  141. resetSearchForm () {
  142. this.queryParam.productName = ''
  143. this.queryParam.productCode = ''
  144. this.$refs.table.refresh(true)
  145. },
  146. pageInit (buyerSn) {
  147. this.buyerSn = buyerSn
  148. const arr = [
  149. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  150. { title: '产品编码', dataIndex: 'productCode', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '产品名称', dataIndex: 'productName', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  152. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  153. // { title: '当前售价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '申请退货数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
  155. { title: '退货原因', dataIndex: 'returnReason', width: '10%', align: 'center', scopedSlots: { customRender: 'returnReason' } },
  156. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  157. ]
  158. if (this.$hasPermissions('B_isShowPrice') && this.isShowPrice) { // 售价权限
  159. arr.splice(4, 0, { title: '当前售价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  160. }
  161. this.columns = arr
  162. this.resetSearchForm()
  163. },
  164. // 选择配件
  165. handleAdd (row) {
  166. this.$emit('add', row)
  167. },
  168. refreshData () {
  169. this.$refs.table.refresh()
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="less">
  175. .salesReturnList-wrap{
  176. .redBg-row{
  177. background-color: #f5cdc8;
  178. }
  179. }
  180. </style>