templateList.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="mainBox">
  3. <!--搜索功能 start------------------------------------------------------------>
  4. <div class="layerBox_search">
  5. <div class="layerBoxLine">
  6. <el-row>
  7. <el-col :span="8">
  8. <div class="searchBox">
  9. <div class="searchTitle">网站名称:</div>
  10. <el-input v-model="getApiData.website_name" placeholder="请输入网站名称"></el-input>
  11. </div>
  12. </el-col>
  13. <el-col :span="8">
  14. <div class="searchBox">
  15. <div class="searchTitle">应用状态:</div>
  16. <el-select v-model="getApiData.status" placeholder="请选择应用状态..">
  17. <el-option label="未构建" value="0"></el-option>
  18. <el-option label="未应用" value="1"></el-option>
  19. <el-option label="已应用" value="2"></el-option>
  20. </el-select>
  21. </div>
  22. </el-col>
  23. <el-col :span="8">
  24. <div class="searchBtnBox">
  25. <el-button>重置</el-button>
  26. <el-button type="primary" @click="getData('search')">搜索</el-button>
  27. </div>
  28. </el-col>
  29. </el-row>
  30. </div>
  31. </div>
  32. <!--搜索功能 end------------------------------------------------------------>
  33. <!--表格内容 start------------------------------------------------------------>
  34. <div class="layerBox">
  35. <tableTitle :name="tableDivTitle"/>
  36. <el-row>
  37. <template>
  38. <el-table :data="tableData" style="width: 100%">
  39. <el-table-column fixed prop="website_id" label="网站id" width="80"></el-table-column>
  40. <el-table-column prop="website_name" label="网站名称"></el-table-column>
  41. <el-table-column prop="name" label="风格名称" width="100">
  42. <template slot-scope="scope">
  43. <div v-if="scope.row.name==''||scope.row.name==null">未选择</div>
  44. <div v-else>{{scope.row.name}}</div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="page_type" label="模板页面">
  48. <template slot-scope="scope">
  49. <div v-if="scope.row.page_type==''||scope.row.page_type==null">未选择</div>
  50. <div v-else>{{scope.row.page_type}}</div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column prop="created_at" label="创建时间">
  54. <template slot-scope="scope">
  55. <div v-if="scope.row.created_at==''||scope.row.created_at==null">未创建</div>
  56. <div v-else>{{scope.row.created_at}}</div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="updated_at" label="更新时间">
  60. <template slot-scope="scope">
  61. <div v-if="scope.row.updated_at==''||scope.row.updated_at==null">未更新</div>
  62. <div v-else>{{scope.row.updated_at}}</div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="status" label="状态" width="100">
  66. <template slot-scope="scope">
  67. <div v-if="scope.row.template_status==0">未构建</div>
  68. <div v-if="scope.row.template_status==1">未应用</div>
  69. <div v-if="scope.row.template_status==2">已应用</div>
  70. </template>
  71. </el-table-column>
  72. <el-table-column fixed="right" label="操作" header-align="center" width="180">
  73. <template slot-scope="scope">
  74. <div class="listBtnBox">
  75. <div class="listEditBtn" @click="getDataMain(scope.row.website_id,scope.row.action_id)" v-if="scope.row.action_id!=null"><i class="el-icon-edit-outline"></i>编辑</div>
  76. <div class="listSaveBtn" @click="creatWebsite(scope.row.website_id)" v-else><i class="el-icon-brush"></i>构建</div>
  77. <div class="listMainBtn"><i class="el-icon-link"></i>应用</div>
  78. </div>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. </template>
  83. </el-row>
  84. </div>
  85. <div class="alignBox">
  86. <el-row>
  87. <el-col :span="24">
  88. <el-pagination :current-page="getApiData.page" @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-size="10" layout="total, prev, pager, next, jumper" :total="allCount"></el-pagination>
  89. </el-col>
  90. </el-row>
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. //表格标题
  96. import tableTitle from './public/tableTitle';
  97. //引入公用样式
  98. import '@/styles/global.less';
  99. //步骤条
  100. import step from './public/step';
  101. export default {
  102. components: {
  103. tableTitle,//表格标题
  104. step//步骤条
  105. },
  106. data() {
  107. return {
  108. //1.列表和分页相关 start ------------------------------------------------------------>
  109. templateStepTitle:"仅需四步,即可完成模板创建",
  110. tableDivTitle:"模板列表",
  111. useTemplateName:"已选择风格",
  112. windowStatus:false,//弹出框
  113. tableData:[],//内容
  114. getApiData:{
  115. website_name:"",
  116. status:"",
  117. page:1,//当前是第几页
  118. pageSize:10,//一共多少条
  119. },
  120. allCount:20,//总条数
  121. //分页相关 end ------------------------------------------------------------>
  122. }
  123. },
  124. methods: {
  125. //0.全局操作 start ------------------------------------------------------------>
  126. //上一步
  127. goBase(){
  128. this.$router.push({
  129. path: '/templateBase',
  130. query: {
  131. id: this.editId
  132. }
  133. });
  134. },
  135. //下一步
  136. goCreat(id){
  137. let data = {
  138. id:id
  139. }
  140. this.$router.push({
  141. path: '/templateCreat',
  142. query: {
  143. id: this.editId
  144. }
  145. });
  146. },
  147. //0.全局操作 end ------------------------------------------------------------>
  148. //1.请求数据 start ------------------------------------------------------------>
  149. //1.1 开始请求列表信息方法
  150. getData(){
  151. this.$store.dispatch('template/getWebsiteintel',this.getApiData).then(res=> {
  152. if(res.code!=200){
  153. this.$message.error(res.message)
  154. this.tableData = [];
  155. this.page = 1;
  156. this.allCount = 0;
  157. }else{
  158. let newData = [];
  159. for (let item of res.data.rows) {
  160. if (item.page_type != null) {
  161. for (let idx = 0; idx < item.page_type.length; idx++) {
  162. if (item.page_type[idx] == "1") {item.page_type[idx] = "首页"}
  163. if (item.page_type[idx] == "2") {item.page_type[idx] = "分类页"}
  164. if (item.page_type[idx] == "3") {item.page_type[idx] = "列表页"}
  165. if (item.page_type[idx] == "4") {item.page_type[idx] = "详情页"}
  166. if (item.page_type[idx] == "5") {item.page_type[idx] = "搜索页"}
  167. if (item.page_type[idx] == "6") {item.page_type[idx] = "自定义列表页"}
  168. if (item.page_type[idx] == "7") {item.page_type[idx] = "自定义详情页"}
  169. }
  170. // 将数组转换为字符串,并去掉两端的 [ 和 ]
  171. item.page_type = item.page_type.join(", ");
  172. }
  173. newData.push(item);
  174. }
  175. this.tableData = newData; //给与内容
  176. this.allCount = res.data.count; //给与总条数
  177. }
  178. })
  179. },
  180. //1.2 列表内容分页
  181. //直接跳转
  182. handleSizeChange(val) {
  183. this.getApiData.page = val;
  184. this.getData();
  185. },
  186. //1.3 点击分页
  187. handleCurrentChange(val) {
  188. this.getApiData.page = val;
  189. this.getData();
  190. },
  191. //列表和分页相关 end ------------------------------------------------------------>
  192. //2.跳转操作 start ------------------------------------------------------------>
  193. //构建网站
  194. creatWebsite(website_id){
  195. this.$store.dispatch('template/addWebsiteTemplateintel',{website_id:website_id}).then(res=> {
  196. if(res.code!=200){
  197. this.$message.error(res.message)
  198. }else{
  199. //可以进入下一步,带着website_id过去
  200. this.$router.push({
  201. path: '/templateBase',
  202. query: {
  203. website_id: website_id
  204. }
  205. });
  206. }
  207. })
  208. },
  209. //编辑网站
  210. getDataMain(website_id,step){
  211. //根据步骤跳转到相应的页面
  212. if(step==1){
  213. this.$router.push({
  214. path: '/templateBase',
  215. query: {
  216. website_id: website_id,
  217. step:step
  218. }
  219. });
  220. }
  221. if(step==1){
  222. this.$router.push({
  223. path: '/templateBase',
  224. query: {
  225. website_id: website_id,
  226. step:step
  227. }
  228. });
  229. }
  230. if(step==2){
  231. this.$router.push({
  232. path: '/templateStyle',
  233. query: {
  234. website_id: website_id,
  235. step:step
  236. }
  237. });
  238. }
  239. if(step>2){
  240. this.$router.push({
  241. path: '/templateCreat',
  242. query: {
  243. website_id: website_id,
  244. step:step
  245. }
  246. });
  247. }
  248. }
  249. //2.跳转操作 end ------------------------------------------------------------>
  250. },
  251. mounted(){
  252. this.getData();
  253. }
  254. }
  255. </script>
  256. <style scoped lang="less">
  257. .searchBtnBox {
  258. padding-top: 26px;
  259. text-align: right;
  260. }
  261. .paginationBox {
  262. padding: 20px 0 0 0;
  263. text-align: center;
  264. }
  265. .btnBox {
  266. padding:0 0 40px 0;
  267. text-align: center;
  268. }
  269. </style>