index.vue 12 KB

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