123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="subPage">
  3. <div class="system-table-search">
  4. <div class="flex-h">
  5. <div class="flex-item flex-h">
  6. <el-button size="mini" type="success" @click='addMajorProjects'>新增售楼处项目专题</el-button>
  7. </div>
  8. <ul>
  9. <li>
  10. <!-- <span>选择案场:</span> -->
  11. <el-select v-model="tableSearch.caseId" placeholder="请选择">
  12. <el-option
  13. key="all"
  14. label="所有案场"
  15. value="all">
  16. </el-option>
  17. <el-option
  18. v-for="item in caseList"
  19. :key="item.CaseId"
  20. :label="item.CaseName"
  21. :value="item.CaseId">
  22. </el-option>
  23. </el-select>
  24. </li>
  25. </ul>
  26. <tableSearch value="请输入项目专题名称" @exportSearchKey="searchList"></tableSearch>
  27. </div>
  28. <div class="moreFilter"></div>
  29. </div>
  30. <div class="system-table-box">
  31. <el-table
  32. :data="tableData"
  33. stripe
  34. style="width: 100%">
  35. <el-table-column
  36. prop="Name"
  37. label="名称">
  38. </el-table-column>
  39. <el-table-column
  40. prop="Title"
  41. label="标题">
  42. </el-table-column>
  43. <el-table-column
  44. prop="CaseName"
  45. label="对应案场">
  46. </el-table-column>
  47. <el-table-column
  48. prop="CreateDate"
  49. label="创建时间">
  50. </el-table-column>
  51. <el-table-column label="操作" width="450">
  52. <template slot-scope="scope">
  53. <el-button
  54. size="mini"
  55. type="primary"
  56. @click="showItem(scope.$index, scope.row)"><span v-if="scope.row.Status === 1">取消前台展示</span><span v-if="scope.row.Status === 0">前台展示</span></el-button>
  57. <el-button
  58. size="mini"
  59. type="warning"
  60. v-if="scope.row.Status === 0"
  61. @click="editItem(scope.$index, scope.row)">编辑</el-button>
  62. <el-button
  63. size="mini"
  64. type="success"
  65. v-clipboard:copy="returnUrl(scope.row.CmsCaseId)"
  66. v-clipboard:success="onCopy"
  67. v-clipboard:error="onError"
  68. >点击复制链接</el-button>
  69. <el-button
  70. size="mini"
  71. type="danger"
  72. v-if="scope.row.Status === 0"
  73. @click="deleteItem(scope.$index, scope.row)">删除</el-button>
  74. </template>
  75. </el-table-column>
  76. </el-table>
  77. </div>
  78. <el-pagination
  79. @current-change="handleCurrentChange"
  80. :current-page.sync="postData.currentPage"
  81. :page-size="postData.pageSize"
  82. layout="prev, pager, next, jumper"
  83. :total="postData.total">
  84. </el-pagination>
  85. </div>
  86. </template>
  87. <script>
  88. import tableSearch from '@/components/tableSearch/index'
  89. import { mapState, mapActions } from 'vuex'
  90. export default {
  91. name: '',
  92. data () {
  93. return {
  94. postData: {
  95. currentPage: 1, // 当前页码
  96. pageSize: 10,
  97. total: 0,
  98. },
  99. tableSearch: { // 表格搜索条件
  100. key: '', // 搜索关键字
  101. caseId: '', // 案场id
  102. },
  103. tableData: []
  104. }
  105. },
  106. computed: {
  107. ...mapState({
  108. OrgId: x => x.app.user.OrgId,
  109. caseList: x => x.app.cases.list,
  110. defaultCaseId: x => x.app.cases.default
  111. })
  112. },
  113. components: {
  114. tableSearch,
  115. },
  116. created () {
  117. this.updateSystemInfo().then(() => {
  118. // this.tableSearch.caseId = this.defaultCaseId
  119. this.getList()
  120. })
  121. },
  122. methods: {
  123. ...mapActions(['updateSystemInfo']),
  124. handleCurrentChange (val) {
  125. this.postData.currentPage = val
  126. this.getList()
  127. },
  128. showItem (index, data) { // 前台显示
  129. let api = data.Status === 1 ? this.$api.cms.caseHide : this.$api.cms.caseShow
  130. this.$ajax(api.url, {
  131. method: api.method,
  132. urlData: {
  133. id: data.CmsCaseId
  134. }
  135. }).then(res => {
  136. this.$message({
  137. message: '编辑成功',
  138. type: 'success',
  139. duration: 1000
  140. })
  141. this.getList()
  142. }).catch(msg => {
  143. })
  144. },
  145. editItem (index, row) { // 编辑
  146. this.$router.push({ name: 'editIndexCase', query: { id: row.CmsCaseId } })
  147. },
  148. returnUrl (id) {
  149. return window.location.origin + window.location.pathname + 'user.html#/majorProjects?id=' + id
  150. },
  151. deleteItem (index, row) { // 删除
  152. this.$confirm('确认删除此项目专题?', '提示', {
  153. confirmButtonText: '确定',
  154. cancelButtonText: '取消',
  155. type: 'warning'
  156. }).then(() => {
  157. this.deleteInfo(row.CmsCaseId)
  158. }).catch(() => {
  159. this.$message({
  160. type: 'info',
  161. message: '已取消删除'
  162. })
  163. })
  164. },
  165. searchList (key) { // 搜索列表
  166. this.tableSearch.key = key
  167. this.getList()
  168. },
  169. addMajorProjects () {
  170. this.$router.push({ name: 'editIndexCase' })
  171. },
  172. getList () {
  173. this.tableData = []
  174. this.$ajax(this.$api.cms.case.url, {
  175. method: this.$api.cms.case.method,
  176. queryData: {
  177. page: this.postData.currentPage,
  178. pagesize: this.postData.pageSize,
  179. caseid: this.tableSearch.caseId === 'all' ? '' : this.tableSearch.caseId,
  180. name: this.tableSearch.key
  181. }
  182. }).then(res => {
  183. for (let i = 0; i < res.list.length; i++) {
  184. res.list[i].CreateDate = this.toolClass.dateFormat(res.list[i].CreateDate)
  185. }
  186. this.tableData = res.list
  187. this.postData.total = res.pagenum
  188. this.postData.currentPage = res.page
  189. }).catch(msg => {
  190. })
  191. },
  192. deleteInfo (id) {
  193. this.$ajax(this.$api.cms.deleteCase.url, {
  194. method: this.$api.cms.deleteCase.method,
  195. urlData: {
  196. id: id
  197. }
  198. }).then(res => {
  199. this.$message({
  200. type: 'success',
  201. message: '删除成功!'
  202. })
  203. this.getList()
  204. }).catch(msg => {
  205. })
  206. },
  207. onCopy () {
  208. this.$message({
  209. type: 'success',
  210. message: '复制成功!'
  211. })
  212. },
  213. onError () {
  214. this.$message({
  215. type: 'error',
  216. message: '复制失败!'
  217. })
  218. },
  219. }
  220. }
  221. </script>
  222. <!-- Add "scoped" attribute to limit CSS to this component only -->
  223. <style lang="scss" scoped>
  224. </style>