queryPart.vue 8.7 KB

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