activeQueryPart.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchForm">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="出库仓库" prop="warehouseSn" required>
  9. <chooseWarehouse ref="warehouse" :allowClear="false" v-model="queryParam.warehouseSn" :isDefault="true" @load="loadWarehouse"></chooseWarehouse>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-code" 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-name" 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-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="产品品牌">
  30. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品分类">
  35. <ProductType id="productInfoList-productType" v-model="productType" @change="changeProductType"></ProductType>
  36. </a-form-item>
  37. </a-col>
  38. </template>
  39. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  40. <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  41. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  42. <a @click="advanced=!advanced" style="margin: 0 5px">
  43. {{ advanced ? '收起' : '展开' }}
  44. <a-icon :type="advanced ? 'up' : 'down'"/>
  45. </a>
  46. </a-col>
  47. </a-row>
  48. </a-form>
  49. </div>
  50. <a-tabs type="card" @change="changeTab">
  51. <a-tab-pane v-for="item in tabList" :key="item.val" :tab="item.text"></a-tab-pane>
  52. </a-tabs>
  53. <!-- 列表 -->
  54. <s-table
  55. class="sTable"
  56. ref="table"
  57. size="small"
  58. :rowKey="(record) => record.id"
  59. :columns="columns"
  60. :data="loadData"
  61. :customRow="handleClickRow"
  62. :scroll="{ y: tableHeight }"
  63. :defaultLoadData="false"
  64. :pageSize="50"
  65. bordered>
  66. <!-- 销售数量 -->
  67. <template slot="nums" slot-scope="text, record">
  68. <div @dblclick.stop>
  69. <a-input-number
  70. size="small"
  71. v-model="record.salesNums"
  72. :precision="0"
  73. :min="1"
  74. :max="999999"
  75. style="width: 100%;"
  76. placeholder="请输入" />
  77. </div>
  78. </template>
  79. <!-- 产品名称 -->
  80. <template slot="productName" slot-scope="text, record">
  81. <div class="ellipsisCon">
  82. <a-tooltip placement="rightBottom">
  83. <template slot="title">
  84. <span>{{ text }}</span>
  85. </template>
  86. <span class="ellipsisText">{{ text }}</span>
  87. </a-tooltip>
  88. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
  89. </div>
  90. </template>
  91. <!-- 操作 -->
  92. <template slot="action" slot-scope="text, record">
  93. <a-button
  94. size="small"
  95. type="link"
  96. class="button-info"
  97. :loading="newLoading"
  98. @click="handleAdd(record)"
  99. :disabled="!record.productPrice || record.productPrice<=0"
  100. id="productInfoList-edit-btn">添加</a-button>
  101. </template>
  102. </s-table>
  103. </div>
  104. </template>
  105. <script>
  106. import { commonMixin } from '@/utils/mixin'
  107. import { queryPromoProductPage } from '@/api/stock'
  108. import ProductType from '@/views/common/productType.js'
  109. import ProductBrand from '@/views/common/productBrand.js'
  110. import chooseWarehouse from '@/views/common/chooseWarehouse'
  111. import { STable, VSelect } from '@/components'
  112. export default {
  113. name: 'ActiveQueryPart',
  114. mixins: [commonMixin],
  115. components: { STable, VSelect, ProductBrand, ProductType, chooseWarehouse },
  116. props: {
  117. newLoading: Boolean
  118. },
  119. data () {
  120. return {
  121. advanced: false, // 高级搜索 展开/关闭
  122. showSetting: false, // 设置弹框
  123. productType: [],
  124. buyerSn: '',
  125. queryParam: { // 查询条件
  126. productCode: '', // 产品编码
  127. productName: '', // 产品名称
  128. productOrigCode: '', // 原厂编码
  129. productBrandSn: undefined, // 产品品牌
  130. productTypeSn1: '', // 产品一级分类
  131. productTypeSn2: '', // 产品二级分类
  132. productTypeSn3: '', // 产品三级分类
  133. warehouseSn: undefined
  134. },
  135. defaultWarehouseSn: undefined, // 默认仓库sn
  136. tableHeight: 300,
  137. disabled: false, // 查询、重置按钮是否可操作
  138. promoProductClz: 'GATE',
  139. promoRuleData: null,
  140. tabList:[],
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. this.disabled = true
  144. this.queryParam.dealerSn = this.buyerSn
  145. this.queryParam.promoProductClz = this.promoProductClz
  146. return queryPromoProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: '1', pricingState: 'PRICED' })).then(res => {
  147. let data
  148. if (res.status == 200) {
  149. data = res.data
  150. data.list = data.list.filter(item => item != null)
  151. const no = (data.pageNo - 1) * data.pageSize
  152. for (var i = 0; i < data.list.length; i++) {
  153. data.list[i].no = no + i + 1
  154. data.list[i].salesNums = 1
  155. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  156. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  157. const productUnit = data.list[i].productUnit || '--'
  158. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  159. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  160. data.list[i].unitQtyV = data.list[i].unitQty + data.list[i].unitTypeDictValue
  161. }
  162. this.disabled = false
  163. }
  164. return data
  165. })
  166. }
  167. }
  168. },
  169. computed: {
  170. columns () {
  171. const arr = [
  172. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  173. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, width: '18%', align: 'left' },
  174. { title: '原厂编码', dataIndex: 'productOrigCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  175. { title: '品牌', dataIndex: 'productBrandName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  176. { title: '出库仓库', dataIndex: 'warehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  177. { title: '库存数量', dataIndex: 'currentStockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. // { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '包装数', dataIndex: 'packQtyV', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '起订量', dataIndex: 'unitQtyV', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  181. { title: '下单数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '8%', align: 'center' },
  182. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  183. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  184. ]
  185. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  186. arr.splice(6, 0, { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  187. }
  188. return arr
  189. }
  190. },
  191. watch:{
  192. advanced(a,b){
  193. this.tableHeight = window.innerHeight - (a ? 395 : 350)
  194. }
  195. },
  196. methods: {
  197. loadWarehouse (sn) {
  198. this.defaultWarehouseSn = sn
  199. this.queryParam.warehouseSn = sn
  200. if(this.buyerSn){
  201. this.resetSearchForm()
  202. }
  203. },
  204. // 切换tab
  205. changeTab(e){
  206. this.promoProductClz = e
  207. this.resetSearchForm()
  208. },
  209. // 双击列表
  210. handleClickRow (record) {
  211. const _this = this
  212. return {
  213. on: {
  214. dblclick: (event) => {
  215. if (!record.productPrice || record.productPrice <= 0) {
  216. _this.$message.info('该产品暂时不能添加')
  217. } else {
  218. event.stopPropagation()
  219. _this.$emit('add', record, 0, this.promoProductClz)
  220. }
  221. }
  222. }
  223. }
  224. },
  225. // 查询
  226. searchForm () {
  227. if (this.queryParam.warehouseSn) {
  228. this.$refs.table.refresh(true)
  229. } else {
  230. this.$message.info('请选择仓库')
  231. }
  232. },
  233. // 重置
  234. resetSearchForm () {
  235. this.queryParam.productCode = ''
  236. this.queryParam.productName = ''
  237. this.queryParam.productOrigCode = ''
  238. this.queryParam.productBrandSn = undefined
  239. this.queryParam.productTypeSn1 = ''
  240. this.queryParam.productTypeSn2 = ''
  241. this.queryParam.productTypeSn3 = ''
  242. this.productType = []
  243. this.queryParam.warehouseSn = this.defaultWarehouseSn
  244. this.$refs.table.refresh(true)
  245. },
  246. pageInit (data, promo) {
  247. this.buyerSn = data.buyerSn
  248. this.promoRuleData = promo.promotionRule
  249. this.queryParam.dealerLevel = data.buyerLevel
  250. this.queryParam.promoRuleSn = promo.promoRuleSn
  251. const tabList = []
  252. if(this.promoRuleData){
  253. if(this.promoRuleData.gateFlag==='1'){
  254. tabList.push({text:'门槛产品',val:'GATE'})
  255. }
  256. if(this.promoRuleData.promotionRuleType!='PROMO_PROD'){
  257. tabList.push({text:'正价产品',val:'REGULAR'})
  258. }
  259. if(this.promoRuleData.regularPromotionSameFlag==='0'){
  260. tabList.push({text:'促销产品',val:'GIFT'})
  261. }
  262. if(this.promoRuleData.promotionRuleType=='PROMO_PROD'){
  263. tabList.push({text:'特价产品',val:'DISCOUNT'})
  264. }
  265. }
  266. this.tabList = tabList
  267. this.promoProductClz = tabList[0].val
  268. this.tableHeight = window.innerHeight - 350
  269. },
  270. // 刷新当前页面
  271. resetCurForm () {
  272. const _this = this
  273. _this.$nextTick(() => {
  274. _this.$refs.table.refresh()
  275. })
  276. },
  277. // 选择配件
  278. handleAdd (row) {
  279. this.$emit('add', row, 0, this.promoProductClz)
  280. },
  281. // 产品分类 change
  282. changeProductType (val, opt) {
  283. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  284. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  285. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  286. }
  287. }
  288. }
  289. </script>
  290. <style lang="less" scoped>
  291. .productInfoList-wrap{
  292. /deep/ .ant-tabs-bar{
  293. margin-bottom: 5px!important;
  294. }
  295. }
  296. </style>