activeQueryPart.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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, x: 1040 }"
  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="productPrice" slot-scope="text, record">
  81. {{ text||text==0 ? toThousands(text) : '--' }} <span title="原价" v-if="promoProductClz == 'GIFT' || promoProductClz == 'DISCOUNT'">({{ record.origPrice||record.origPrice==0 ? toThousands(record.origPrice) : '--' }})</span>
  82. </template>
  83. <!-- 产品名称 -->
  84. <template slot="productName" slot-scope="text, record">
  85. <div class="ellipsisCon">
  86. <a-tooltip placement="rightBottom">
  87. <template slot="title">
  88. <span>{{ text }}</span>
  89. </template>
  90. <span class="ellipsisText">{{ text }}</span>
  91. </a-tooltip>
  92. <!-- <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge> -->
  93. </div>
  94. </template>
  95. <!-- 操作 -->
  96. <template slot="action" slot-scope="text, record">
  97. <a-button
  98. size="small"
  99. type="link"
  100. class="button-info"
  101. :loading="newLoading"
  102. @click="handleAdd(record)"
  103. v-if="promoProductClz!='GIFT' ? record.productPrice : record.origPrice"
  104. id="productInfoList-edit-btn">添加</a-button>
  105. <span v-else>--</span>
  106. </template>
  107. </s-table>
  108. </div>
  109. </template>
  110. <script>
  111. import { commonMixin } from '@/utils/mixin'
  112. import { queryPromoProductPage } from '@/api/stock'
  113. import ProductType from '@/views/common/productType.js'
  114. import ProductBrand from '@/views/common/productBrand.js'
  115. import chooseWarehouse from '@/views/common/chooseWarehouse'
  116. import { STable, VSelect } from '@/components'
  117. export default {
  118. name: 'ActiveQueryPart',
  119. mixins: [commonMixin],
  120. components: { STable, VSelect, ProductBrand, ProductType, chooseWarehouse },
  121. props: {
  122. newLoading: Boolean
  123. },
  124. data () {
  125. return {
  126. advanced: false, // 高级搜索 展开/关闭
  127. showSetting: false, // 设置弹框
  128. productType: [],
  129. buyerSn: '',
  130. queryParam: { // 查询条件
  131. productCode: '', // 产品编码
  132. productName: '', // 产品名称
  133. productOrigCode: '', // 原厂编码
  134. productBrandSn: undefined, // 产品品牌
  135. productTypeSn1: '', // 产品一级分类
  136. productTypeSn2: '', // 产品二级分类
  137. productTypeSn3: '', // 产品三级分类
  138. warehouseSn: undefined
  139. },
  140. defaultWarehouseSn: undefined, // 默认仓库sn
  141. tableHeight: 300,
  142. disabled: false, // 查询、重置按钮是否可操作
  143. promoProductClz: 'GATE',
  144. promoRuleData: null,
  145. tabList:[],
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. this.queryParam.dealerSn = this.buyerSn
  150. this.queryParam.promoProductClz = this.promoProductClz
  151. return queryPromoProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: '1', pricingState: 'PRICED' })).then(res => {
  152. let data
  153. if (res.status == 200) {
  154. data = res.data
  155. data.list = data.list.filter(item => item != null)
  156. const no = (data.pageNo - 1) * data.pageSize
  157. for (var i = 0; i < data.list.length; i++) {
  158. data.list[i].no = no + i + 1
  159. data.list[i].salesNums = 1
  160. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  161. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  162. const productUnit = data.list[i].productUnit || '--'
  163. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  164. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  165. if(data.list[i].unitType=='SL'){
  166. data.list[i].unitQtyV = data.list[i].unitQty ? (data.list[i].unitQty + data.list[i].productUnit) : '--'
  167. }else{
  168. data.list[i].unitQtyV = data.list[i].productPackQty&&data.list[i].unitQty ? ((data.list[i].productPackQty*data.list[i].unitQty) + data.list[i].productUnit) : '--'
  169. }
  170. }
  171. this.disabled = false
  172. }
  173. return data
  174. })
  175. }
  176. }
  177. },
  178. computed: {
  179. columns () {
  180. const arr = [
  181. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' } },
  182. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, align: 'left' },
  183. { title: '原厂编码', dataIndex: 'productOrigCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  184. { title: '品牌', dataIndex: 'productBrandName', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  185. { title: '出库仓库', dataIndex: 'warehouseName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  186. { title: '库存数量', dataIndex: 'currentStockQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '单位', dataIndex: 'productUnit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  188. // { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  189. { title: '包装数', dataIndex: 'packQtyV', width: '60px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  190. // { title: '起订量', dataIndex: 'unitQtyV', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  191. { title: '下单数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '80px', align: 'center', fixed: 'right' },
  192. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '60px', align: 'center', fixed: 'right' }
  193. ]
  194. let idx = 7
  195. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  196. arr.splice(idx, 0, { title: '售价', dataIndex: 'productPrice', width: '100px', align: 'right', scopedSlots: { customRender: 'productPrice' } })
  197. idx = idx + 1
  198. }
  199. // 促销品没有起订量
  200. if(this.promoProductClz != 'GIFT'){
  201. arr.splice(idx+1, 0,{ title: '起订量', dataIndex: 'unitQtyV', width: '60px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  202. }
  203. return arr
  204. }
  205. },
  206. watch:{
  207. advanced(a,b){
  208. this.tableHeight = window.innerHeight - (a ? 375 : 330)
  209. }
  210. },
  211. methods: {
  212. loadWarehouse (sn) {
  213. this.defaultWarehouseSn = sn
  214. this.queryParam.warehouseSn = sn
  215. if(this.buyerSn){
  216. this.resetSearchForm()
  217. }
  218. },
  219. // 切换tab
  220. changeTab(e){
  221. this.promoProductClz = e
  222. this.resetSearchForm()
  223. },
  224. // 双击列表
  225. handleClickRow (record) {
  226. const _this = this
  227. return {
  228. on: {
  229. dblclick: (event) => {
  230. _this.handleAdd(record)
  231. }
  232. }
  233. }
  234. },
  235. // 查询
  236. searchForm () {
  237. if (this.queryParam.warehouseSn) {
  238. this.$refs.table.refresh(true)
  239. } else {
  240. this.$message.info('请选择仓库')
  241. }
  242. },
  243. // 重置
  244. resetSearchForm () {
  245. this.queryParam.productCode = ''
  246. this.queryParam.productName = ''
  247. this.queryParam.productOrigCode = ''
  248. this.queryParam.productBrandSn = undefined
  249. this.queryParam.productTypeSn1 = ''
  250. this.queryParam.productTypeSn2 = ''
  251. this.queryParam.productTypeSn3 = ''
  252. this.productType = []
  253. this.queryParam.warehouseSn = this.defaultWarehouseSn
  254. this.$refs.table.refresh(true)
  255. },
  256. pageInit (data, promo) {
  257. this.buyerSn = data.buyerSn
  258. this.promoRuleData = promo.promotionRule
  259. this.queryParam.dealerLevel = data.buyerLevel
  260. this.queryParam.promoRuleSn = promo.promoRuleSn
  261. this.queryParam.salesPromoSn = promo.salesPromoSn
  262. const tabList = []
  263. if(this.promoRuleData){
  264. if(this.promoRuleData.gateFlag==='1'){
  265. tabList.push({text:'门槛产品',val:'GATE'})
  266. }
  267. if(this.promoRuleData.promotionRuleType!='PROMO_PROD'){
  268. tabList.push({text:'正价产品',val:'REGULAR'})
  269. }
  270. if(this.promoRuleData.regularPromotionSameFlag==='0'||this.promoRuleData.scopeFlag==='0'||(this.promoRuleData.promotionRuleType=='BUY_PROD_GIVE_MONEY'&&this.promoRuleData.scopeFlag==='1')){
  271. const levelText = this.promoRuleData.scopeLevel ? '(阶梯'+this.promoRuleData.scopeLevel+')' : ''
  272. tabList.push({text:'促销产品'+ levelText ,val:'GIFT'})
  273. }
  274. if(this.promoRuleData.promotionRuleType=='PROMO_PROD'){
  275. tabList.push({text:'特价产品',val:'DISCOUNT'})
  276. }
  277. }
  278. this.tabList = tabList
  279. this.promoProductClz = tabList[0].val
  280. this.tableHeight = window.innerHeight - 330
  281. this.resetSearchForm()
  282. },
  283. // 刷新当前页面
  284. resetCurForm () {
  285. const _this = this
  286. _this.$nextTick(() => {
  287. _this.$refs.table.refresh()
  288. })
  289. },
  290. // 选择配件
  291. handleAdd (row) {
  292. this.$emit('add', row, 0, this.promoProductClz)
  293. },
  294. // 产品分类 change
  295. changeProductType (val, opt) {
  296. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  297. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  298. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  299. }
  300. }
  301. }
  302. </script>
  303. <style lang="less" scoped>
  304. .productInfoList-wrap{
  305. /deep/ .ant-tabs-bar{
  306. margin-bottom: 5px!important;
  307. }
  308. }
  309. </style>