list.vue 18 KB

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