queryPart.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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="{ 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. style="width: 100%;"
  52. placeholder="请输入" />
  53. </div>
  54. </template>
  55. <span slot="customTitle">
  56. 操作
  57. <a-popover>
  58. <template slot="content">
  59. 双击列表配件可快速选中添加
  60. </template>
  61. <a-icon type="question-circle" theme="twoTone" />
  62. </a-popover>
  63. </span>
  64. <!-- 操作 -->
  65. <template slot="action" slot-scope="text, record">
  66. <a-button
  67. size="small"
  68. type="primary"
  69. class="button-info"
  70. :loading="newLoading"
  71. :disabled="grabFlag == '1'&&record.refundableQty==0"
  72. @click="handleAdd(record)"
  73. >添加</a-button>
  74. </template>
  75. </s-table>
  76. </div>
  77. </template>
  78. <script>
  79. import { salesQueryByReturn } from '@/api/salesReturn'
  80. import { queryStockProductPage } from '@/api/stock'
  81. import { STable, VSelect } from '@/components'
  82. export default {
  83. name: 'QueryPart',
  84. components: { STable, VSelect },
  85. props: {
  86. newLoading: Boolean
  87. },
  88. data () {
  89. return {
  90. buyerSn: '',
  91. grabFlag: '',
  92. priceType: '',
  93. queryParam: { // 查询条件
  94. salesBillNo: '', // 销售单号
  95. productName: '', // 产品名称
  96. productCode: '' // 产品编码
  97. },
  98. disabled: false, // 查询、重置按钮是否可操作
  99. columns: [],
  100. // 加载数据方法 必须为 Promise 对象
  101. loadData: parameter => {
  102. this.disabled = true
  103. // 抓单时
  104. if (this.grabFlag == 1) {
  105. this.queryParam.buyerSn = this.buyerSn
  106. }
  107. // 不抓单
  108. if (this.grabFlag == 0) {
  109. this.queryParam.dealerSn = this.buyerSn
  110. }
  111. const fun = [queryStockProductPage, salesQueryByReturn]
  112. return fun[this.grabFlag](Object.assign(parameter, this.queryParam)).then(res => {
  113. let data
  114. if (res.status == 200) {
  115. data = res.data
  116. const no = (data.pageNo - 1) * data.pageSize
  117. for (var i = 0; i < data.list.length; i++) {
  118. data.list[i].no = no + i + 1
  119. data.list[i].qty = 1
  120. }
  121. this.disabled = false
  122. }
  123. return data
  124. })
  125. }
  126. }
  127. },
  128. methods: {
  129. // 双击列表选择配件
  130. handleClickRow (record) {
  131. const _this = this
  132. return {
  133. on: {
  134. dblclick: (event) => {
  135. if (_this.grabFlag == '1' && record.refundableQty == 0) {
  136. _this.$message.info('该产品暂时不能添加')
  137. } else {
  138. event.stopPropagation()
  139. _this.$emit('add', record)
  140. }
  141. }
  142. }
  143. }
  144. },
  145. // 重置
  146. resetSearchForm () {
  147. this.queryParam.salesBillNo = ''
  148. this.queryParam.productName = ''
  149. this.queryParam.productCode = ''
  150. this.$refs.table.refresh(true)
  151. },
  152. pageInit (buyerSn, grabFlag) {
  153. this.buyerSn = buyerSn
  154. this.grabFlag = grabFlag
  155. // 抓单
  156. if (this.grabFlag == 1) {
  157. const arr = [
  158. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  159. { title: '销售单号', dataIndex: 'salesBillNo', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '产品编码', dataIndex: 'productEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  162. // { title: '售价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  163. { title: '剩余可退数量', dataIndex: 'refundableQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  164. { title: '本次退货数量', dataIndex: 'qty', width: '8%', align: 'center', scopedSlots: { customRender: 'qty' } },
  165. // { title: '采购价', dataIndex: 'showCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  168. ]
  169. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  170. arr.splice(4, 0, { title: '售价', dataIndex: 'price', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  171. }
  172. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  173. const ind = this.$hasPermissions('B_isShowPrice') ? 7 : 6
  174. arr.splice(ind, 0, { title: '采购价', dataIndex: 'showCost', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  175. }
  176. this.columns = arr
  177. } else {
  178. const arr = [
  179. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  180. { title: '产品编码', dataIndex: 'productCode', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '产品名称', dataIndex: 'productName', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  182. // { title: '当前售价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  183. { title: '退货数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
  184. // { title: '采购价', dataIndex: 'lastStockCost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  185. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  186. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  187. ]
  188. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  189. arr.splice(3, 0, { title: '当前售价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  190. }
  191. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  192. const ind = this.$hasPermissions('B_isShowPrice') ? 5 : 4
  193. arr.splice(ind, 0, { title: '采购价', dataIndex: 'lastStockCost', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  194. }
  195. this.columns = arr
  196. }
  197. this.resetSearchForm()
  198. },
  199. // 选择配件
  200. handleAdd (row) {
  201. this.$emit('add', row)
  202. },
  203. refreshData () {
  204. this.$refs.table.refresh()
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="less">
  210. .salesReturnList-wrap{
  211. .redBg-row{
  212. background-color: #f5cdc8;
  213. }
  214. }
  215. </style>