list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchForm(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品名称">
  14. <a-input id="productInfoList-name" v-model.trim="queryParam.name" 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-origCode" v-model.trim="queryParam.origCode" 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. <ProductBrand id="productInfoList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></ProductBrand>
  26. </a-form-item>
  27. </a-col>
  28. <!-- <a-col :md="6" :sm="24">
  29. <a-form-item label="产品分类">
  30. <ProductType id="productInfoList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  31. </a-form-item>
  32. </a-col> -->
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品状态">
  35. <v-select code="ONLINE_FLAG" id="productInfoList-onlineFalg" v-model="queryParam.onlineFalg " allowClear placeholder="请选择产品状态"></v-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="启用状态">
  40. <v-select code="ENABLE_FLAG" id="productInfoList-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择启用状态"></v-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-item label="是否有库存">
  45. <a-select allowClear v-model="queryParam.stockEmptyFlag" placeholder="请选择查看是否有库存">
  46. <a-select-option value="0">
  47. </a-select-option>
  48. <a-select-option value="1">
  49. </a-select-option>
  50. </a-select>
  51. </a-form-item>
  52. </a-col>
  53. </template>
  54. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  55. <a-button type="primary" @click="searchForm(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  56. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  57. <a @click="advanced=!advanced" style="margin-left: 5px">
  58. {{ advanced ? '收起' : '展开' }}
  59. <a-icon :type="advanced ? 'up' : 'down'"/>
  60. </a>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </div>
  65. <!-- 操作按钮 -->
  66. <div class="table-operator" v-if="$hasPermissions('B_JgProduct_enable')">
  67. <a-row :gutter="16">
  68. <a-col class="gutter-row" :span="8">
  69. <a-dropdown>
  70. <a-menu slot="overlay" @click="handleMenuClick">
  71. <a-menu-item key="1"> 批量启用</a-menu-item>
  72. <a-menu-item key="2"> 批量禁用</a-menu-item>
  73. </a-menu>
  74. <a-button ghost type="danger"> 批量操作 <a-icon type="down" /> </a-button>
  75. </a-dropdown>
  76. <span v-if="rowSelectionInfo&&rowSelectionInfo.selectedRowKeys">已选 {{ rowSelectionInfo.selectedRowKeys.length }} 项</span>
  77. </a-col>
  78. <a-col class="gutter-row " :span="16" style="text-align: right;">
  79. <a-dropdown v-model="showCell">
  80. <a-button type="link" class="button-default"> <a-icon type="setting" /> 显示</a-button>
  81. <a-menu slot="overlay">
  82. <a-menu-item>
  83. <a-checkbox v-model="isTerminalPrice">
  84. 自定义终端价
  85. </a-checkbox>
  86. </a-menu-item>
  87. <a-menu-item>
  88. <a-checkbox v-model="isCarOwnersPrice">
  89. 自定义车主价
  90. </a-checkbox>
  91. </a-menu-item>
  92. <a-menu-item>
  93. <a-checkbox v-model="isCityPrice">
  94. 市级价
  95. </a-checkbox>
  96. </a-menu-item>
  97. <a-menu-item>
  98. <a-checkbox v-model="isZdPrice">
  99. 终端价
  100. </a-checkbox>
  101. </a-menu-item>
  102. <a-menu-item>
  103. <a-checkbox v-model="isCzPrice">
  104. 车主价
  105. </a-checkbox>
  106. </a-menu-item>
  107. </a-menu>
  108. </a-dropdown>
  109. <a-divider type="vertical" style="margin:5px 0;"/>
  110. <a-dropdown>
  111. <a-menu slot="overlay" @click="handleActions">
  112. <a-menu-item key="2">
  113. <a-icon type="export" />自定义报价导出
  114. </a-menu-item>
  115. <a-menu-item key="1">
  116. <a-icon type="import" />自定义报价导入
  117. </a-menu-item>
  118. </a-menu>
  119. <a-button type="link" class="button-default"> <a-icon type="unordered-list" /> 更多</a-button>
  120. </a-dropdown>
  121. </a-col>
  122. </a-row>
  123. </div>
  124. <!-- 列表 -->
  125. <s-table
  126. class="sTable fixPagination"
  127. ref="table"
  128. :style="{ height: tableHeight+84.5+'px' }"
  129. size="small"
  130. :row-selection="$hasPermissions('B_JgProduct_enable')?{columnWidth: '3%', getCheckboxProps: record => ({props: {disabled: record.enabledFlag == undefined}})}:null"
  131. @rowSelection="rowSelectionFun"
  132. rowKeyName="productSn"
  133. :rowKey="(record) => record.productSn"
  134. :columns="columns"
  135. :data="loadData"
  136. :scroll="{ y: tableHeight }"
  137. :defaultLoadData="false"
  138. bordered>
  139. <!-- 产品图片 -->
  140. <template slot="imageUrl" slot-scope="text, record">
  141. <div v-if="record.productPicList && record.productPicList.length>0">
  142. <img :src="record.productPicList[0].imageUrl+'?x-oss-process=image/resize,h_30,m_lfit' || ''" width="30" height="30" class="imageUrl" @click="inited(record.productPicList)" />
  143. </div>
  144. <span v-else>--</span>
  145. </template>
  146. <!-- 产品分类 -->
  147. <template slot="productType" slot-scope="text, record">
  148. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  149. <span v-else>--</span>
  150. </template>
  151. <!-- 状态 -->
  152. <template slot="enabledFlag" slot-scope="text, record">
  153. <a-switch
  154. checkedChildren="启用"
  155. unCheckedChildren="禁用"
  156. v-if="$hasPermissions('B_JgProduct_enable')&&record.enabledFlag!=undefined"
  157. @change="changeStatus(record)"
  158. :checked="record.enabledFlag == 1 ? true : false"
  159. />
  160. <span v-else :style="{ color: record.enabledFlag == 1 ? '#00aa00' : '#999' }">
  161. {{ record.enabledFlag == 1 ? '已启用' : (record.enabledFlag!=undefined?'已禁用':'--') }}
  162. </span>
  163. </template>
  164. <!-- 操作 -->
  165. <template slot="action" slot-scope="text, record">
  166. <a-button
  167. size="small"
  168. type="link"
  169. class="button-success"
  170. @click="handleDetail(record)"
  171. id="productInfoList-detail-btn">详情</a-button>
  172. <a-button
  173. size="small"
  174. type="link"
  175. class="button-primary"
  176. @click="handleEditPrice(record)"
  177. id="productInfoList-price-btn">自定义报价</a-button>
  178. </template>
  179. </s-table>
  180. <!-- 导入产品 -->
  181. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="resetSearchForm" />
  182. <!-- 自定义报价弹窗 -->
  183. <editPriceModal :openModal="openEditPriceModal" :itemId="itemId" @ok="searchForm(false)" @close="openEditPriceModal=false"></editPriceModal>
  184. </a-card>
  185. </template>
  186. <script>
  187. import { commonMixin } from '@/utils/mixin'
  188. import { productList, getCurrentDealer, productUpdate, productExportPrice } from '@/api/product'
  189. import ProductType from '../../common/productType.js'
  190. import ProductBrand from '../../common/productBrand.js'
  191. import { STable, VSelect } from '@/components'
  192. import { downloadExcel } from '@/libs/JGPrint.js'
  193. import editPriceModal from './editPriceModal.vue'
  194. import importGuideModal from './importGuideModal.vue'
  195. export default {
  196. name: 'ProductJgList',
  197. components: { STable, VSelect, ProductType, ProductBrand, editPriceModal, importGuideModal },
  198. mixins: [commonMixin],
  199. data () {
  200. return {
  201. advanced: true, // 高级搜索 展开/关闭
  202. showCell: false,
  203. tableHeight: 0,
  204. productType: [],
  205. queryParam: { // 查询条件
  206. code: '', // 产品编码
  207. name: '', // 产品名称
  208. origCode: '', // 原厂编码
  209. sysFlag: '1',
  210. productBrandSn: undefined, // 产品品牌
  211. productTypeSn1: '', // 产品一级分类
  212. productTypeSn2: '', // 产品二级分类
  213. productTypeSn3: '', // 产品三级分类
  214. onlineFalg: '',
  215. enabledFlag: '1',
  216. stockEmptyFlag: undefined
  217. },
  218. openGuideModal: false,
  219. isTerminalPrice: true,
  220. isCarOwnersPrice: true,
  221. isCityPrice: true,
  222. isZdPrice: true,
  223. isCzPrice: true,
  224. openEditPriceModal: false, // 自定义报价弹窗
  225. iconShowFlag: false, // 列表配置图标显示
  226. disabled: false, // 查询、重置按钮是否可操作
  227. exportLoading: false, // 导出loading
  228. dateFormat: 'YYYY-MM-DD',
  229. // 加载数据方法 必须为 Promise 对象
  230. loadData: parameter => {
  231. this.disabled = true
  232. this.spinning = true
  233. return productList(Object.assign(parameter, this.queryParam)).then(res => {
  234. let data
  235. if (res.status == 200) {
  236. data = res.data
  237. const no = (data.pageNo - 1) * data.pageSize
  238. for (var i = 0; i < data.list.length; i++) {
  239. data.list[i].no = no + i + 1
  240. }
  241. this.disabled = false
  242. }
  243. this.spinning = false
  244. return data
  245. })
  246. },
  247. openModal: false, // 查看客户详情 弹框
  248. itemId: '', // 当前产品id
  249. productTypeList: [], // 分类下拉数据
  250. rowSelectionInfo: null,
  251. currentDealerInfo: {}
  252. }
  253. },
  254. computed: {
  255. columns () {
  256. const _this = this
  257. let arr = [
  258. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  259. { title: '产品编码', dataIndex: 'code', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  260. { title: '产品名称', dataIndex: 'name', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
  261. { title: '原厂编码', dataIndex: 'origCode', width: '12%', align: 'center', customRender: function (text) { return (!text || text == ' ') ? '--' : text } }
  262. ]
  263. const cArr = [
  264. // { title: '终端价', dataIndex: 'terminalPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  265. // { title: '车主价', dataIndex: 'carOwnersPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  266. // { title: '自定义终端价', dataIndex: 'price1', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  267. // { title: '自定义车主价', dataIndex: 'price2', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  268. { title: '可用库存', dataIndex: 'currentStockQty', width: '7%', align: 'center', customRender: function (text) { return text || text == 0 ? text : '--' } },
  269. { title: '产品状态', dataIndex: 'status', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  270. { title: '启用状态', scopedSlots: { customRender: 'enabledFlag' }, width: '7%', align: 'center' },
  271. { title: '产品图片', scopedSlots: { customRender: 'imageUrl' }, width: '6%', align: 'center' },
  272. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  273. ]
  274. if (_this.currentDealerInfo.dealerLevel && _this.currentDealerInfo.dealerLevel == 'PROVINCE') { // 省级
  275. arr.push(
  276. { title: '省级价', dataIndex: 'provincePrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  277. )
  278. if (_this.isCityPrice) {
  279. arr.push(
  280. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  281. )
  282. }
  283. } else if (_this.currentDealerInfo.dealerLevel && _this.currentDealerInfo.dealerLevel == 'CITY' && _this.isCityPrice) { // 市级
  284. arr.push(
  285. { title: '市级价', dataIndex: 'cityPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  286. )
  287. }
  288. if (_this.currentDealerInfo.isShowSpecialPrice && _this.currentDealerInfo.isShowSpecialPrice == '1') { // 是否展示特约价
  289. arr.push({ title: '特约价', dataIndex: 'specialPrice', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  290. }
  291. if (_this.isZdPrice) {
  292. arr.push({ title: '终端价', dataIndex: 'terminalPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  293. }
  294. if (_this.isTerminalPrice) {
  295. arr.push({ title: '自定义终端价', dataIndex: 'dealerProductPrice.terminalPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  296. }
  297. if (_this.isCzPrice) {
  298. arr.push({ title: '车主价', dataIndex: 'carOwnersPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  299. }
  300. if (_this.isCarOwnersPrice) {
  301. arr.push({ title: '自定义车主价', dataIndex: 'dealerProductPrice.carOwnersPrice', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  302. }
  303. arr = [...arr, ...cArr]
  304. return arr
  305. }
  306. },
  307. methods: {
  308. inited (viewer) {
  309. if (viewer) {
  310. const imageUrl = []
  311. viewer.map(item => {
  312. imageUrl.push(item.imageUrl)
  313. })
  314. this.$viewerApi({
  315. images: imageUrl
  316. })
  317. }
  318. },
  319. // 详情
  320. handleDetail (row) {
  321. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  322. },
  323. // 查询
  324. searchForm (flag) {
  325. this.$refs.table.clearSelected() // 清空表格选中项
  326. this.$refs.table.refresh(flag)
  327. },
  328. // 重置
  329. resetSearchForm () {
  330. this.queryParam.code = ''
  331. this.queryParam.name = ''
  332. this.queryParam.origCode = ''
  333. this.queryParam.productBrandSn = undefined
  334. this.queryParam.productTypeSn1 = ''
  335. this.queryParam.productTypeSn2 = ''
  336. this.queryParam.productTypeSn3 = ''
  337. this.queryParam.onlineFalg = ''
  338. this.queryParam.enabledFlag = '1'
  339. this.queryParam.stockEmptyFlag = undefined
  340. this.productType = []
  341. this.$refs.table.refresh(true)
  342. this.rowSelectionInfo = null
  343. this.$refs.table.clearSelected()
  344. },
  345. // 获取省级经销商、市级经销商和特约经销商信息
  346. getCurrentDealerInfo () {
  347. getCurrentDealer().then(res => {
  348. if (res.status == 200) {
  349. this.currentDealerInfo = res.data
  350. }
  351. })
  352. },
  353. filterOption (input, option) {
  354. return (
  355. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  356. )
  357. },
  358. // 产品分类 change
  359. changeProductType (val, opt) {
  360. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  361. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  362. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  363. },
  364. // 启用 禁用
  365. changeStatus (record) {
  366. this.$confirm({
  367. title: '提示',
  368. content: record.enabledFlag == '1' ? '产品被禁用后,不能再销售,确定禁用吗?' : '确定启用吗?',
  369. centered: true,
  370. onOk: () => {
  371. this.setEnable(record.enabledFlag == 1 ? '0' : '1', [record.productSn])
  372. }
  373. })
  374. },
  375. // 启用 禁用
  376. setEnable (enabledFlag, snList) {
  377. const params = {
  378. productSnList: snList,
  379. enabledFlag: enabledFlag
  380. }
  381. this.spinning = true
  382. productUpdate(params).then(res => {
  383. if (res.status == 200) {
  384. this.$message.success(res.message)
  385. this.$refs.table.clearSelected()
  386. this.rowSelectionInfo = null
  387. this.$refs.table.refresh()
  388. this.spinning = false
  389. } else {
  390. this.$refs.table.refresh()
  391. this.spinning = false
  392. }
  393. })
  394. },
  395. // 表格选中项
  396. rowSelectionFun (obj) {
  397. this.rowSelectionInfo = obj || null
  398. },
  399. // 批量操作
  400. handleOutbounds (type) {
  401. console.log(this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length)
  402. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length <= 0)) {
  403. this.$message.warning('请在列表勾选后再进行批量操作!')
  404. return
  405. }
  406. this.$confirm({
  407. title: '提示',
  408. content: type == '2' ? '产品被禁用后,不能再销售,确定批量禁用吗?' : '确定批量启用吗?',
  409. centered: true,
  410. onOk: () => {
  411. this.setEnable(type == '2' ? '0' : '1', this.rowSelectionInfo.selectedRowKeys)
  412. }
  413. })
  414. },
  415. handleMenuClick (e) {
  416. this.handleOutbounds(e.key)
  417. },
  418. pageInit () {
  419. const _this = this
  420. this.$nextTick(() => { // 页面渲染完成后的回调
  421. _this.setTableH()
  422. })
  423. this.getCurrentDealerInfo()
  424. },
  425. setTableH () {
  426. const tableSearchH = this.$refs.tableSearch.offsetHeight
  427. this.tableHeight = window.innerHeight - tableSearchH - 235
  428. },
  429. // 打开自定义报价弹窗
  430. handleEditPrice (row) {
  431. this.itemId = row.productSn
  432. const _this = this
  433. this.$nextTick(() => {
  434. _this.openEditPriceModal = true
  435. })
  436. },
  437. // 导入导出
  438. handleActions (e) {
  439. if (e.key == 1) {
  440. this.openGuideModal = true
  441. } else {
  442. this.handleExport()
  443. }
  444. },
  445. handleExport () {
  446. const _this = this
  447. const params = _this.queryParam
  448. _this.exportLoading = true
  449. _this.spinning = true
  450. productExportPrice(params).then(res => {
  451. downloadExcel(res, '产品信息管理(箭冠)')
  452. _this.exportLoading = false
  453. _this.spinning = false
  454. })
  455. }
  456. },
  457. watch: {
  458. advanced (newValue, oldValue) {
  459. const _this = this
  460. this.$nextTick(() => { // 页面渲染完成后的回调
  461. _this.setTableH()
  462. })
  463. },
  464. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  465. this.setTableH()
  466. }
  467. },
  468. mounted () {
  469. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  470. this.pageInit()
  471. this.resetSearchForm()
  472. }
  473. },
  474. activated () {
  475. // 如果是新页签打开,则重置当前页面
  476. if (this.$store.state.app.isNewTab) {
  477. this.pageInit()
  478. this.resetSearchForm()
  479. }
  480. },
  481. beforeRouteEnter (to, from, next) {
  482. next(vm => {})
  483. }
  484. }
  485. </script>
  486. <style lang="less" scoped>
  487. .setTableList{
  488. text-align: right;
  489. // position: relative;
  490. span{
  491. margin-right: 10px;
  492. color:#56a2fb;
  493. }
  494. .setTableList-box{
  495. padding:10px 12px;
  496. border:1px solid #d5d5d5;
  497. border-radius: 5px;
  498. background:#fff;
  499. text-align: left;
  500. position: absolute;
  501. top:22px;
  502. right:0;
  503. z-index: 99999;
  504. div{
  505. margin-bottom: 10px;
  506. &:last-child{
  507. margin-bottom: 0px;
  508. }
  509. }
  510. }
  511. }
  512. </style>