activeQueryPart.vue 14 KB

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