index.vue 13 KB

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