activeQueryPart.vue 14 KB

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