index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <a-card size="small" :bordered="false" class="easyPassShopping-wrap jg-page-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 操作按钮 -->
  5. <!-- <div class="table-operator">
  6. <a-button
  7. type="primary"
  8. class="button-info"
  9. v-if="shoppingMallStatus=='0'&&$hasPermissions('B_openShopProduct')"
  10. icon="unlock"
  11. id="easyPassShopping-open-btn"
  12. :loading="iconLoading"
  13. @click="editShoppingStatus('1')">
  14. 打开商城
  15. </a-button>
  16. <a-button
  17. type="primary"
  18. v-if="shoppingMallStatus=='1'&&$hasPermissions('B_closeShopProduct')"
  19. icon="poweroff"
  20. id="easyPassShopping-close-btn"
  21. :loading="iconLoading"
  22. @click="editShoppingStatus('0')">
  23. 关闭商城
  24. </a-button>
  25. <div style="margin:10px 0;color:gray;" v-if="$hasPermissions('B_openShopProduct')||$hasPermissions('B_closeShopProduct')">
  26. {{ shoppingMallStatus=='0'?'开启':'关闭' }}商城后,易码通{{ shoppingMallStatus=='0'?'会':'不会' }}显示商城
  27. </div>
  28. </div> -->
  29. <!-- 搜索条件 -->
  30. <div ref="tableSearch" class="table-page-search-wrapper">
  31. <a-form layout="inline" id="easyPassShopping-form" @keyup.enter.native="$refs.table.refresh(true)">
  32. <a-row :gutter="15">
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品名称"><a-input id="easyPassShopping-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称" /></a-form-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-item label="产品编码/原厂编码"><a-input id="easyPassShopping-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码/原厂编码" /></a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="产品品牌">
  41. <productBrand id="easyPassShopping-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.productBrandSn"></productBrand>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="产品分类">
  46. <productType id="easyPassShopping-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></productType>
  47. </a-form-item>
  48. </a-col>
  49. <a-col :md="6" :sm="24">
  50. <a-form-item label="商城类目">
  51. <a-cascader
  52. id="easyPassShopping-category"
  53. expandTrigger="hover"
  54. :changeOnSelect="true"
  55. :fieldNames="fieldNames"
  56. :options="categoryOptions"
  57. placeholder="请选择商城类目"
  58. @change="changeCategory"
  59. allowClear
  60. v-model="category" />
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-item label="产品商城状态">
  65. <v-select code="SHOP_PRODUCT_STATUS" id="easyPassShopping-status" v-model="queryParam.status" allowClear placeholder="请选择产品商城状态"></v-select>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="热销产品">
  70. <v-select code="FLAG" id="easyPassShopping-hotFlag" v-model="queryParam.hotFlag" allowClear placeholder="请选择热销产品"></v-select>
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24" style="margin-bottom: 10px">
  74. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="easyPassShopping-refresh">查询</a-button>
  75. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="easyPassShopping-reset">重置</a-button>
  76. </a-col>
  77. </a-row>
  78. </a-form>
  79. </div>
  80. <!-- 列表 -->
  81. <s-table
  82. class="sTable fixPagination"
  83. ref="table"
  84. :style="{ height: tableHeight+84.5+'px' }"
  85. size="small"
  86. :rowKey="(record) => record.id"
  87. :columns="columns"
  88. :data="loadData"
  89. :scroll="{ y: tableHeight }"
  90. :defaultLoadData="false"
  91. bordered>
  92. <!-- 产品编码 -->
  93. <template slot="productCode" slot-scope="text, record">
  94. <span>{{ record.productCode || '--' }}</span>
  95. <a-badge count="热" v-if="record.hotFlag==1" :number-style="{ zoom:'80%',marginLeft:'5px' }"></a-badge>
  96. </template>
  97. <!-- 产品分类 -->
  98. <template slot="productType" slot-scope="text, record">
  99. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  100. <span v-else>--</span>
  101. </template>
  102. <!-- 商城类目 -->
  103. <template slot="categoryName" slot-scope="text, record">
  104. <span v-if="record.categoryName1 || record.categoryName2">{{ record.categoryName1 }} {{ record.categoryName2 ? '>' : '' }} {{ record.categoryName2 }}</span>
  105. <span v-else>--</span>
  106. </template>
  107. <!-- 售价类型 -->
  108. <template slot="priceType" slot-scope="text, record">
  109. {{ record.priceType&&record.priceType==='OCS_PRICE'?'商城价':'自定义终端价' }}
  110. </template>
  111. </s-table>
  112. </a-spin>
  113. </a-card>
  114. </template>
  115. <script>
  116. import { commonMixin } from '@/utils/mixin'
  117. // 组件
  118. import { STable, VSelect } from '@/components'
  119. import productType from '@/views/common/productType.js'
  120. import productBrand from '@/views/common/productBrand.js'
  121. // 接口
  122. import { shopProductList, findMallParam, updateMallParam, queryExtList } from '@/api/shopProduct'
  123. export default {
  124. name: 'ShelfProductTemplList',
  125. components: { STable, VSelect, productType, productBrand },
  126. mixins: [commonMixin],
  127. data () {
  128. const _this = this
  129. return {
  130. spinning: false,
  131. iconLoading: false, // 打开关闭商城按钮状态
  132. tableHeight: 0, // 表格高度
  133. disabled: false, // 查询、重置按钮是否可操作
  134. // 查询条件
  135. queryParam: {
  136. productName: '', // 产品名称
  137. productCode: '', // 产品编码/原厂编码
  138. productBrandSn: undefined, // 产品品牌
  139. productTypeSn1: '', // 产品一级分类
  140. productTypeSn2: '', // 产品二级分类
  141. productTypeSn3: '', // 产品三级分类
  142. status: undefined, // 产品商城状态
  143. categorySn1: undefined, // 产品一级类目
  144. categorySn2: undefined, // 产品二级类目
  145. orderBy: 'createDate', // 按照创建时间排序
  146. hotFlag: undefined, // 热销产品
  147. categoryStatus: '1'// 状态 默认值1
  148. },
  149. productType: [], // 产品分类
  150. categoryOptions: [], // 产品类目列表
  151. category: [],
  152. fieldNames: { label: 'categoryName', value: 'categorySn', children: 'shopCategoryList' },
  153. shoppingMallStatus: '0', // 商城状态1:开启 0 关闭
  154. // 表头
  155. columns: [
  156. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  157. { title: '产品编码', dataIndex: 'productCode', scopedSlots: { customRender: 'productCode' }, width: '12%', align: 'center' },
  158. { title: '产品名称', dataIndex: 'productName', width: '13%', align: 'left', ellipsis: true, customRender: function (text) { return text || '--' } },
  159. { title: '原厂编码', dataIndex: 'origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '产品品牌', dataIndex: 'productBrandName', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '9%', align: 'center' },
  162. { title: '商城类目', scopedSlots: { customRender: 'categoryName' }, width: '9%', align: 'center' },
  163. { title: '自定义终端价', dataIndex: 'terminalPrice', width: '10%', align: 'right', customRender: function (text) { return text || text == 0 ? _this.toThousands(text, 2) : '--' } },
  164. { title: '商城价', dataIndex: 'ocsPrice', width: '6%', align: 'right', customRender: function (text) { return text || text == 0 ? _this.toThousands(text, 2) : '--' } },
  165. { title: '车主价', dataIndex: 'carOwnersPrice', width: '6%', align: 'right', customRender: function (text) { return text || text == 0 ? _this.toThousands(text, 2) : '--' } },
  166. { title: '售价', dataIndex: 'price', width: '6%', align: 'right', customRender: function (text) { return text || text == 0 ? _this.toThousands(text, 2) : '--' } },
  167. { title: '售价类型', scopedSlots: { customRender: 'priceType' }, width: '7%', align: 'center' },
  168. { title: '产品商城状态', dataIndex: 'statusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } }
  169. ],
  170. // 加载数据方法 必须为 Promise 对象
  171. loadData: parameter => {
  172. this.disabled = true
  173. this.spinning = true
  174. this.queryParam.dealerSn = this.$store.state.user.authOrgs[0].orgSn || undefined
  175. return shopProductList(Object.assign(parameter, this.queryParam)).then(res => {
  176. let data
  177. if (res.status == 200) {
  178. data = res.data
  179. // 计算表格序号
  180. const no = (data.pageNo - 1) * data.pageSize
  181. for (var i = 0; i < data.list.length; i++) {
  182. data.list[i].no = no + i + 1
  183. }
  184. this.disabled = false
  185. }
  186. this.spinning = false
  187. return data
  188. })
  189. }
  190. }
  191. },
  192. methods: {
  193. // 产品分类 change
  194. changeProductType (val, opt) {
  195. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  196. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  197. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  198. },
  199. // 商城类目
  200. changeCategory (val, opt) {
  201. this.queryParam.categorySn1 = val[0] ? val[0] : ''
  202. this.queryParam.categorySn2 = val[1] ? val[1] : ''
  203. },
  204. // 获取商城类目列表
  205. getCategoryList () {
  206. const _this = this
  207. _this.spinning = true
  208. queryExtList({ status: 1 }).then(res => {
  209. if (res.status == 200) {
  210. this.categoryOptions = res.data || []
  211. }
  212. _this.spinning = false
  213. })
  214. },
  215. // 重置
  216. resetSearchForm () {
  217. this.queryParam.productName = ''
  218. this.queryParam.productCode = ''
  219. this.queryParam.productBrandSn = undefined
  220. this.queryParam.productTypeSn1 = undefined
  221. this.queryParam.productTypeSn2 = undefined
  222. this.queryParam.productTypeSn3 = undefined
  223. this.queryParam.status = undefined
  224. this.queryParam.categorySn1 = undefined
  225. this.queryParam.categorySn2 = undefined
  226. this.queryParam.hotFlag = undefined
  227. this.queryParam.orderBy = 'createDate'
  228. this.queryParam.categoryStatus = '1'
  229. this.productType = []
  230. this.category = []
  231. this.$refs.table.refresh(true)
  232. },
  233. // 获取初始商城打开、关闭状态
  234. getShoppingStatus () {
  235. const _this = this
  236. _this.spinning = true
  237. findMallParam({}).then(res => {
  238. if (res.status == 200) {
  239. this.shoppingMallStatus = res.data.paramValue || '0'
  240. }
  241. _this.spinning = false
  242. })
  243. },
  244. // 修改商城状态
  245. editShoppingStatus (typeVal) {
  246. const _this = this
  247. this.$confirm({
  248. title: (typeVal == '0' ? '关闭' : '开启') + '商城',
  249. content: '确认' + (typeVal == '0' ? '关闭' : '开启') + '吗,' + (typeVal == '0' ? '关闭' : '开启') + '后修理厂' + (typeVal == '0' ? '不可' : '可') + '在易码通查看商城',
  250. centered: true,
  251. okText: (typeVal == '0' ? '关闭商城' : '开启商城'),
  252. onOk () {
  253. _this.iconLoading = true
  254. updateMallParam({ paramValue: typeVal }).then(res => {
  255. if (res.status == 200) {
  256. _this.$message.success(res.message)
  257. _this.shoppingMallStatus = typeVal
  258. _this.iconLoading = false
  259. } else {
  260. _this.iconLoading = false
  261. }
  262. })
  263. }
  264. })
  265. },
  266. // 表格高度
  267. setTableH () {
  268. const tableSearchH = this.$refs.tableSearch.offsetHeight
  269. this.tableHeight = window.innerHeight - tableSearchH - 200
  270. },
  271. // 初始化页面
  272. pageInit () {
  273. const _this = this
  274. // this.getShoppingStatus()
  275. this.getCategoryList()
  276. this.$nextTick(() => { // 页面渲染完成后的回调
  277. _this.setTableH()
  278. })
  279. }
  280. },
  281. mounted () {
  282. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  283. this.pageInit()
  284. this.resetSearchForm()
  285. }
  286. },
  287. watch: {
  288. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  289. this.setTableH()
  290. }
  291. },
  292. activated () {
  293. // 如果是新页签打开,则重置当前页面
  294. if (this.$store.state.app.isNewTab) {
  295. this.pageInit()
  296. this.resetSearchForm()
  297. }
  298. // 仅刷新列表,不重置页面
  299. if (this.$store.state.app.updateList) {
  300. this.pageInit()
  301. this.$refs.table.refresh()
  302. }
  303. }
  304. }
  305. </script>