queryPart.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="productInfoList-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. <rangeDate ref="rangeDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-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="productInfoList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced && grabFlag == 1">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="销售单号">
  25. <a-input id="productInfoList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  26. </a-form-item>
  27. </a-col>
  28. </template>
  29. <a-col :md="6" :sm="24" style="margin-bottom: 10px">
  30. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  32. <a @click="advanced=!advanced" style="margin:0 15px 0 8px" v-if="grabFlag == 1">
  33. {{ advanced ? '收起' : '展开' }}
  34. <a-icon :type="advanced ? 'up' : 'down'"/>
  35. </a>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. <!-- 列表 -->
  41. <s-table
  42. class="sTable"
  43. ref="table"
  44. size="small"
  45. :rowKey="(record) => record.id"
  46. :columns="columns"
  47. :data="loadData"
  48. :customRow="handleClickRow"
  49. :defaultLoadData="false"
  50. :scroll="{ y: 300 }"
  51. bordered>
  52. <!-- 价格 -->
  53. <template slot="price" slot-scope="text, record">{{ text }}</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.qty==record.hasReturnQty)"
  71. @click="handleAdd(record)"
  72. >添加</a-button>
  73. </template>
  74. </s-table>
  75. </div>
  76. </template>
  77. <script>
  78. import { salesReturnProductList } from '@/api/salesReturn'
  79. import { stockList } from '@/api/stock'
  80. import { STable, VSelect } from '@/components'
  81. import rangeDate from '@/views/common/rangeDate.vue'
  82. export default {
  83. name: 'QueryPart',
  84. components: { STable, VSelect, rangeDate },
  85. props: {
  86. // buyerSn: {
  87. // type: [Number, String],
  88. // default: ''
  89. // },
  90. newLoading: Boolean,
  91. grabFlag: [Number, String]
  92. // priceType: [Number, String]
  93. },
  94. data () {
  95. return {
  96. advanced: false, // 高级搜索 展开/关闭
  97. queryParam: { // 查询条件
  98. beginDate: '',
  99. endDate: '',
  100. salesBillNo: '', // 销售单号
  101. productName: '', // 产品名称
  102. productCode: '' // 产品编码
  103. },
  104. buyerSn: '',
  105. priceType: '',
  106. disabled: false, // 查询、重置按钮是否可操作
  107. columns: [],
  108. // 加载数据方法 必须为 Promise 对象
  109. loadData: parameter => {
  110. this.disabled = true
  111. // 抓单时
  112. if (this.grabFlag == 1) {
  113. this.queryParam.buyerSn = this.buyerSn
  114. }
  115. const fun = [stockList, salesReturnProductList]
  116. if (this.grabFlag == 0) {
  117. this.queryParam.salePriceType = this.priceType
  118. }
  119. return fun[this.grabFlag](Object.assign(parameter, this.queryParam)).then(res => {
  120. const data = res.data
  121. const no = (data.pageNo - 1) * data.pageSize
  122. for (var i = 0; i < data.list.length; i++) {
  123. data.list[i].no = no + i + 1
  124. if (this.grabFlag == 0) {
  125. data.list[i].salePrice = data.list[i].lastStockCost
  126. data.list[i].putCost = data.list[i].lastStockCost
  127. }
  128. }
  129. this.listData = data.list || []
  130. this.disabled = false
  131. return data
  132. })
  133. },
  134. listData: []
  135. }
  136. },
  137. mounted () {
  138. // 抓单
  139. if (this.grabFlag == 1) {
  140. this.columns = [
  141. { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
  142. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  143. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  144. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '销售单号', dataIndex: 'salesBillNo', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '销售审核时间', dataIndex: 'auditDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '售价', dataIndex: 'price', align: 'center', width: '5%', scopedSlots: { customRender: 'price' } },
  148. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '销售数量', dataIndex: 'qty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '已退数量', dataIndex: 'hasReturnQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '7%', align: 'center' }]
  152. } else {
  153. this.columns = [
  154. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  155. { title: '产品编码', dataIndex: 'productCode', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
  156. { title: '产品名称', dataIndex: 'productName', width: '22%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  157. { title: '原厂编码', dataIndex: 'productOrigCode', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '售价', dataIndex: 'salePrice', width: '10%', align: 'center', scopedSlots: { customRender: 'price' } },
  159. { title: '单位', dataIndex: 'productUnit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }]
  161. }
  162. },
  163. methods: {
  164. // 时间 change
  165. dateChange (date) {
  166. this.queryParam.beginDate = date[0]
  167. this.queryParam.endDate = date[1]
  168. },
  169. // 双击列表选择配件
  170. handleClickRow (record) {
  171. const _this = this
  172. return {
  173. on: {
  174. dblclick: (event) => {
  175. if ((_this.grabFlag == 1) && (record.qty == record.hasReturnQty)) {
  176. _this.$message.info('该产品暂时不能添加')
  177. } else {
  178. event.stopPropagation()
  179. _this.$emit('add', record)
  180. }
  181. }
  182. }
  183. }
  184. },
  185. // 重置
  186. resetSearchForm () {
  187. this.$refs.rangeDate && this.$refs.rangeDate.resetDate()
  188. this.queryParam.beginDate = ''
  189. this.queryParam.endDate = ''
  190. this.queryParam.salesBillNo = ''
  191. this.queryParam.productName = ''
  192. this.queryParam.productCode = ''
  193. this.$refs.table.refresh(true)
  194. },
  195. pageInit (buyerSn, priceType) {
  196. console.log(buyerSn, priceType)
  197. this.buyerSn = buyerSn
  198. this.priceType = priceType
  199. this.resetSearchForm()
  200. },
  201. refreshData () {
  202. if (this.listData.length > 0) {
  203. this.$refs.table.refresh(true)
  204. }
  205. },
  206. // 选择配件
  207. handleAdd (row) {
  208. this.$emit('add', row, 'new')
  209. }
  210. }
  211. }
  212. </script>