queryPart.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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="default"
  45. :rowKey="(record) => record.id"
  46. :columns="columns"
  47. :data="loadData"
  48. :customRow="handleClickRow"
  49. :defaultLoadData="false"
  50. :scroll="{ x: grabFlag == '1' ? 1700 : 860, 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, salesQueryByReturn } 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 = [salesQueryByReturn, 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: '序号',
  146. dataIndex: 'no',
  147. align: 'center',
  148. width: 100
  149. },
  150. {
  151. title: '产品编码',
  152. dataIndex: 'dealerProductEntity.code',
  153. align: 'center',
  154. sorter: true,
  155. width: 160
  156. },
  157. {
  158. title: '产品名称',
  159. dataIndex: 'dealerProductEntity.name',
  160. align: 'center'
  161. },
  162. {
  163. title: '原厂编码',
  164. dataIndex: 'dealerProductEntity.origCode',
  165. align: 'center',
  166. customRender: function (text) { return text || '--' },
  167. width: 120
  168. },
  169. {
  170. title: '销售单号',
  171. dataIndex: 'salesBillNo',
  172. align: 'center',
  173. width: 160
  174. },
  175. {
  176. title: '销售审核时间',
  177. dataIndex: 'auditTime',
  178. align: 'center',
  179. customRender: function (text) { return text || '--' },
  180. width: 120
  181. },
  182. {
  183. title: '售价',
  184. dataIndex: 'price',
  185. align: 'center',
  186. width: 120,
  187. scopedSlots: { customRender: 'price' }
  188. },
  189. {
  190. title: '单位',
  191. dataIndex: 'dealerProductEntity.unit',
  192. align: 'center',
  193. width: 100
  194. },
  195. {
  196. title: '销售数量',
  197. dataIndex: 'qty',
  198. align: 'center',
  199. width: 100
  200. },
  201. {
  202. title: '已退数量',
  203. dataIndex: 'hasReturnQty',
  204. align: 'center',
  205. width: 120
  206. },
  207. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }]
  208. } else {
  209. this.columns = [{
  210. title: '序号',
  211. dataIndex: 'no',
  212. align: 'center',
  213. width: 100
  214. },
  215. {
  216. title: '产品编码',
  217. dataIndex: 'productCode',
  218. align: 'center',
  219. sorter: true,
  220. width: 160
  221. },
  222. {
  223. title: '产品名称',
  224. dataIndex: 'productName',
  225. align: 'center'
  226. },
  227. {
  228. title: '原厂编码',
  229. dataIndex: 'productOrigCode',
  230. align: 'center',
  231. customRender: function (text) { return text || '--' },
  232. width: 160
  233. },
  234. {
  235. title: '售价',
  236. dataIndex: 'salePrice',
  237. align: 'center',
  238. width: 120,
  239. scopedSlots: { customRender: 'price' }
  240. },
  241. {
  242. title: '单位',
  243. dataIndex: 'unit',
  244. align: 'center',
  245. customRender: function (text) { return text || '--' },
  246. width: 120
  247. },
  248. { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: 100, align: 'center' }]
  249. }
  250. },
  251. methods: {
  252. // 双击列表选择配件
  253. handleClickRow (record) {
  254. const _this = this
  255. return {
  256. on: {
  257. dblclick: (event) => {
  258. event.stopPropagation()
  259. _this.$emit('add', record)
  260. }
  261. }
  262. }
  263. },
  264. // 重置
  265. resetSearchForm () {
  266. this.queryParam.salesBillNo = ''
  267. this.queryParam.productName = ''
  268. this.queryParam.productCode = ''
  269. this.$refs.table.refresh(true)
  270. },
  271. // 选择配件
  272. handleAdd (row) {
  273. this.$emit('add', row, 'new')
  274. }
  275. }
  276. }
  277. </script>