activeQueryPart.vue 12 KB

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