ProductLinesManage.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <div>
  3. <crumbs title="产品线管理">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="产品名称:">
  6. <el-input size="mini" v-model="filter.proName" placeholder="产品名称"></el-input>
  7. </el-select>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button size="mini" @click="filterDatas">确认</el-button>
  11. <router-link to="/admin/LT-CPXGL-TJCPX" style="margin:0 10px">
  12. <el-button size="mini" type="warning">添加产品线</el-button>
  13. </router-link>
  14. </el-form-item>
  15. </el-form>
  16. </crumbs>
  17. <div class="contents">
  18. <el-table :data="list"
  19. border
  20. style="width: 100%">
  21. <el-table-column
  22. type="index"
  23. :index="indexMethod"
  24. label="编号"
  25. width="60">
  26. </el-table-column>
  27. <el-table-column
  28. prop="gmtCreate"
  29. label="建立时间"
  30. :show-overflow-tooltip="true">
  31. </el-table-column>
  32. <el-table-column
  33. prop="name"
  34. label="产品名称">
  35. </el-table-column>
  36. <el-table-column
  37. prop="url"
  38. label="URL"
  39. width="180">
  40. </el-table-column>
  41. <el-table-column
  42. prop="decription"
  43. label="描述" width="120">
  44. </el-table-column>
  45. <el-table-column
  46. prop="accessTypeName"
  47. label="接入方式"
  48. :show-overflow-tooltip="true">
  49. <!--<template slot-scope="scope">
  50. <span v-for="item in linkIn" class="status-span">{{item.name}},</span>
  51. </template>-->
  52. </el-table-column>
  53. <el-table-column
  54. prop="chargeTypeName"
  55. label="收费模式"
  56. :show-overflow-tooltip="true">
  57. <!--<template slot-scope="scope">
  58. <span v-for="item in pays" class="status-span">{{item.name}},</span>
  59. </template>-->
  60. </el-table-column>
  61. <el-table-column
  62. prop="oppendedNum"
  63. label="开通机构数量">
  64. </el-table-column>
  65. <el-table-column
  66. prop="trialStatusName"
  67. label="试用状态">
  68. </el-table-column>
  69. <el-table-column
  70. prop="trialUrl"
  71. label="试用URL"
  72. width="180">
  73. </el-table-column>
  74. <el-table-column
  75. label="状态">
  76. <template slot-scope="scope">
  77. <span v-if="scope.row.serviceStatus == 0">已停用</span>
  78. <span v-if="scope.row.serviceStatus == 1">已启用</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. label="操作" width="150">
  83. <template slot-scope="scope">
  84. <el-button type="text" size="small" @click="toEditProduct(scope.row)">修改</el-button>
  85. <span style="margin:0 3px;">|</span>
  86. <el-button type="text" size="small" @click="showDelDialog(scope.row.id)">删除</el-button>
  87. <span style="margin:0 3px;">|</span>
  88. <el-button type="text" size="small" v-if="scope.row.serviceStatus == 0" @click="updateServiceStatus(scope.row.id,1)">启用</el-button>
  89. <el-button type="text" size="small" v-if="scope.row.serviceStatus == 1" @click="updateServiceStatus(scope.row.id,0)">停用</el-button>
  90. </template>
  91. </el-table-column>
  92. <el-table-column
  93. label="接入明细">
  94. <template slot-scope="scope">
  95. <el-button type="text" size="small" @click="getDetailList(scope.row.id)">详情</el-button>
  96. <!-- <router-link :to="{name:'productDetail', params:{productId:scope.row.id}}"><el-button type="text" size="small">详情</el-button></router-link> -->
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <el-pagination v-if="total>pageSize"
  101. :current-page.sync="currentPage"
  102. @current-change="currentChange"
  103. background
  104. :page-size="pageSize"
  105. layout="total,prev, pager, next, jumper"
  106. :total="total">
  107. </el-pagination>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. import api from '@api/admin.js';
  113. import utils from '@api/utils.js';
  114. export default {
  115. name: 'product-lines-manage',
  116. data: function () {
  117. return {
  118. list: [],
  119. cacheData: {},
  120. currentPage: 1,
  121. pageSize: 10,
  122. total: 0,
  123. linkIn:[],
  124. pays:[],
  125. filter: {
  126. proName: ''
  127. }
  128. }
  129. },
  130. created() {
  131. this.getDataList();
  132. /*const enums = JSON.parse(localStorage.getItem('enumsData'));
  133. this.linkIn = enums&&enums.accessTypeEnum;
  134. this.pays = enums&&enums.chargeTypeEnum;*/
  135. },
  136. methods: {
  137. toEditProduct(row){
  138. this.$router.push({
  139. name:'editProductLine',
  140. params: {info:row}
  141. })
  142. },
  143. filterDatas(){
  144. this.currentPage = 1;
  145. this.getDataList();
  146. },
  147. getDataList() {
  148. const param = this.getFilterItems();
  149. api.getProductLinesManage(param).then((res) => {
  150. if (res.data.code == '0') {
  151. const data = res.data.data;
  152. this.list = data.records;
  153. this.cacheData[param.current] = data.records;
  154. this.total = data.total;
  155. }
  156. }).catch((error) => {
  157. console.log(error);
  158. });
  159. },
  160. getDetailList(id) {
  161. const param = {productId: id,};
  162. api.getProductDetail(param).then((res) => {
  163. if (res.data.code == '0') {
  164. this.$router.push({name:'productDetail', params:{productId: id}})
  165. } else {
  166. this.$message({
  167. showClose: true,
  168. message:res.data.msg,
  169. type:'warning'
  170. });
  171. this.getDataList() //刷新列表
  172. }
  173. }).catch((error) => {
  174. console.log(error);
  175. });
  176. },
  177. getFilterItems() {
  178. const param = {
  179. name: this.filter.proName,
  180. current: this.currentPage,
  181. size: this.pageSize
  182. };
  183. return param;
  184. },
  185. indexMethod(index) {
  186. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  187. },
  188. currentChange(next) {
  189. this.currentPage = next;
  190. if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  191. this.list = this.cacheData[next];
  192. } else {
  193. this.getDataList();
  194. }
  195. },
  196. updateServiceStatus(id,serviceStatus){
  197. const txt = serviceStatus==0?'停用':'启用';
  198. this.showConfirmDialog('确定要'+txt+'该产品线吗?',()=>{
  199. api.updateServiceStatus({id,serviceStatus}).then((res)=>{
  200. if(res.data.code=='0'){
  201. this.getDataList();
  202. this.warning(res.data.msg||'操作成功','success');
  203. }else{
  204. this.warning(res.data.msg);
  205. this.getDataList();
  206. }
  207. }).catch((error)=>{
  208. this.warning(error);
  209. });
  210. });
  211. },
  212. warning(msg,type){
  213. this.$message({
  214. showClose: true,
  215. message:msg,
  216. type:type||'warning'
  217. })
  218. },
  219. showConfirmDialog(msg,resolve){
  220. this.$alert(msg, '提示', {
  221. confirmButtonText: '确定',
  222. type: 'warning'
  223. }).then(() => {
  224. resolve();
  225. }).catch(() => {});
  226. },
  227. showDelDialog(id){
  228. this.showConfirmDialog('确定要删除该产品线吗?',()=>{
  229. api.delProductLine({id}).then((res)=>{
  230. if(res.data.code=='0'){
  231. this.warning(res.data.msg||'操作成功','success');
  232. this.getDataList();
  233. }else{
  234. this.warning(res.data.msg);
  235. }
  236. }).catch((error)=>{
  237. this.warning(error);
  238. })
  239. });
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="less">
  245. @import "../../less/admin.less";
  246. .status-span{
  247. font-size: 12px;
  248. margin-right:10px;
  249. color: unset;
  250. }
  251. </style>