queryPart.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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">
  8. <a-form-item label="审核时间">
  9. <a-range-picker v-model="shDate" id="salesReturn-shDate"/>
  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">
  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">
  30. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  31. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  32. <a @click="advanced=!advanced" style="margin:0 15px 0 8px">
  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="{ x: grabFlag == '1' ? 1620 : 1040, y: 300 }"
  51. bordered>
  52. <!-- 价格 -->
  53. <template slot="price" slot-scope="text, record">
  54. ¥ {{ text }}
  55. </template>
  56. <span slot="customTitle">
  57. 操作
  58. <a-popover>
  59. <template slot="content">
  60. 双击列表配件可快速选中添加
  61. </template>
  62. <a-icon type="question-circle" theme="twoTone" />
  63. </a-popover>
  64. </span>
  65. <!-- 操作 -->
  66. <template slot="action" slot-scope="text, record">
  67. <a-button
  68. size="small"
  69. type="primary"
  70. class="button-info"
  71. :loading="newLoading"
  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 { querySumByProductLocation } from '@/api/stock'
  81. import { STable, VSelect } from '@/components'
  82. import moment from 'moment'
  83. export default {
  84. name: 'QueryPart',
  85. components: { STable, VSelect },
  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. shDate: [],
  99. dateFormat: 'YYYY-MM-DD',
  100. queryParam: { // 查询条件
  101. salesBillNo: '', // 销售单号
  102. productName: '', // 产品名称
  103. productCode: '' // 产品编码
  104. },
  105. disabled: false, // 查询、重置按钮是否可操作
  106. exportLoading: false, // 导出loading
  107. brandData: [], // 下拉数据
  108. typeData: [], // 产品类别 下拉数据
  109. columns: [],
  110. // 加载数据方法 必须为 Promise 对象
  111. loadData: parameter => {
  112. this.disabled = true
  113. // 抓单时
  114. if (this.grabFlag == 1) {
  115. this.queryParam.buyerSn = this.buyerSn
  116. }
  117. // 创建时间
  118. if (this.shDate && this.shDate.length > 0) {
  119. this.queryParam.beginDate = moment(this.shDate[0]).format(this.dateFormat)
  120. this.queryParam.endDate = moment(this.shDate[1]).format(this.dateFormat)
  121. } else {
  122. this.queryParam.beginDate = undefined
  123. this.queryParam.endDate = undefined
  124. }
  125. const fun = [querySumByProductLocation, salesReturnProductList]
  126. if (this.grabFlag == 0) {
  127. this.queryParam.salePriceType = this.priceType
  128. }
  129. return fun[this.grabFlag](Object.assign(parameter, this.queryParam)).then(res => {
  130. const data = res.data
  131. const no = (data.pageNo - 1) * data.pageSize
  132. for (var i = 0; i < data.list.length; i++) {
  133. data.list[i].no = no + i + 1
  134. }
  135. this.disabled = false
  136. return data
  137. })
  138. }
  139. }
  140. },
  141. mounted () {
  142. // 抓单
  143. if (this.grabFlag == 1) {
  144. this.columns = [
  145. { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
  146. { title: '产品编码', dataIndex: 'dealerProductEntity.code', align: 'center', sorter: true, width: 220 },
  147. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center' },
  148. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', align: 'center', customRender: function (text) { return text || '--' }, width: 220 },
  149. { title: '销售单号', dataIndex: 'salesBillNo', align: 'center', width: 220 },
  150. { title: '销售审核时间', dataIndex: 'auditTime', align: 'center', customRender: function (text) { return text || '--' }, width: 160 },
  151. { title: '售价', dataIndex: 'price', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
  152. { title: '单位', dataIndex: 'dealerProductEntity.unit', align: 'center', width: 100 },
  153. { title: '销售数量', dataIndex: 'qty', align: 'center', width: 100 },
  154. { title: '已退数量', dataIndex: 'hasReturnQty', align: 'center', width: 100 },
  155. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }]
  156. } else {
  157. this.columns = [
  158. { title: '序号', dataIndex: 'no', align: 'center', width: 80 },
  159. { title: '产品编码', dataIndex: 'productCode', align: 'center', sorter: true },
  160. { title: '产品名称', dataIndex: 'productName', align: 'center' },
  161. { title: '原厂编码', dataIndex: 'productOrigCode', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '售价', dataIndex: 'salePrice', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
  163. { title: '单位', dataIndex: 'unit', align: 'center', customRender: function (text) { return text || '--' }, width: 100 },
  164. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 100, align: 'center' }]
  165. }
  166. },
  167. methods: {
  168. // 双击列表选择配件
  169. handleClickRow (record) {
  170. const _this = this
  171. return {
  172. on: {
  173. dblclick: (event) => {
  174. event.stopPropagation()
  175. _this.$emit('add', record)
  176. }
  177. }
  178. }
  179. },
  180. // 重置
  181. resetSearchForm () {
  182. this.queryParam.salesBillNo = ''
  183. this.queryParam.productName = ''
  184. this.queryParam.productCode = ''
  185. this.$refs.table.refresh(true)
  186. },
  187. // 选择配件
  188. handleAdd (row) {
  189. this.$emit('add', row, 'new')
  190. }
  191. }
  192. }
  193. </script>