index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class='m-container'>
  3. <h2>
  4. <div class="squrt"></div>问卷管理
  5. </h2>
  6. <div class="m-core">
  7. <el-button type="primary" @click="onQuestionOperation('create')"
  8. v-if="$helpers.permission('/operateManager/questionOperation/create')"
  9. class='newBand'>添加问卷</el-button>
  10. <save-form :inline="true"
  11. @submit="search"
  12. @reset="onReSet"
  13. ref="searchForm"
  14. :model="searchForm">
  15. <el-form-item prop="search">
  16. <el-input
  17. type="text"
  18. clearable
  19. v-model="searchForm.search"
  20. placeholder="问卷编号或名称"
  21. ></el-input>
  22. </el-form-item>
  23. <el-form-item prop="status">
  24. <el-select v-model="searchForm.status"
  25. filterable
  26. placeholder="请选择问卷状态"
  27. clearable>
  28. <el-option label="启用" :value="1"></el-option>
  29. <el-option label="停用" :value="0"></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item>
  33. <el-button type="danger" native-type="submit">搜索</el-button>
  34. <el-button native-type="reset" type="primary">重置</el-button>
  35. </el-form-item>
  36. </save-form>
  37. <!-- 列表 -->
  38. <div class="tableWrap">
  39. <el-table :data='tableList'
  40. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  41. <el-table-column align='center'
  42. prop="id"
  43. label="问卷编号">
  44. <template slot-scope="scope">
  45. <copy-text>{{ scope.row.id }}</copy-text>
  46. </template>
  47. </el-table-column>
  48. <el-table-column align='center'
  49. prop="title"
  50. label="问卷名称">
  51. <template slot-scope="scope">
  52. <!-- <copy-text>{{ scope.row.title }}</copy-text> -->
  53. <overflow-text :text="scope.row.title" ></overflow-text>
  54. </template>
  55. </el-table-column>
  56. <el-table-column align='center'
  57. prop="status"
  58. label="状态">
  59. <template slot-scope="scope">
  60. {{ scope.row.status ? '开启' : '关闭' }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column align='center'
  64. label="操作">
  65. <template slot-scope="scope">
  66. <el-button @click="onQuestionOperation('look', scope.row)"
  67. v-if="$helpers.permission('/operateManager/questionOperation/detail')"
  68. type="text">详情</el-button>
  69. <el-button @click="onOperation(scope.row)"
  70. v-if="$helpers.permission(scope.row.status ? 'questionnaireTopic/updateStatus/stop' : 'questionnaireTopic/updateStatus/start')"
  71. type="text">{{ scope.row.status ? '停用' : '启用' }}</el-button>
  72. <!-- 启用的问卷不能修改 -->
  73. <el-button @click="onQuestionOperation('update', scope.row)"
  74. v-if="$helpers.permission('/operateManager/questionOperation/update') && !scope.row.status"
  75. type="text">修改</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <pagination sync :total.sync="pageInfo.total"
  80. :page.sync="pageInfo.page"
  81. :limit.sync="pageInfo.limit"
  82. :page-sizes="pageInfo.page_size"
  83. @pagination="getList" />
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import pagination from '@/components/Pagination/index'
  90. import { questionnaireTopicQueryPage, questionnaireTopicUpdateStatus } from './api'
  91. export default {
  92. name: 'branchSetting',
  93. components: { pagination },
  94. data () {
  95. return {
  96. searchForm: {
  97. search: null,
  98. status: null
  99. },
  100. tableList: [],
  101. pageInfo: {
  102. // 分页规则
  103. limit: 10, // 限制显示条数
  104. page: 1, // 当前页
  105. total: 0, // 总条数
  106. page_size: [10, 20, 40, 50] // 选择限制显示条数
  107. },
  108. organId: null,
  109. }
  110. },
  111. mounted () {
  112. this.getList()
  113. },
  114. methods: {
  115. getList () {
  116. questionnaireTopicQueryPage({
  117. rows: this.pageInfo.limit,
  118. page: this.pageInfo.page,
  119. ...this.searchForm
  120. }).then(res => {
  121. if (res.code == 200 && res.data) {
  122. this.tableList = res.data.rows
  123. this.pageInfo.total = res.data.total
  124. }
  125. })
  126. },
  127. onQuestionOperation(type, row) {
  128. let str = '问卷'
  129. if(type == 'create') {
  130. str = '添加' + str
  131. } else if(type == 'update') {
  132. str = '修改' + str
  133. } else if(type == 'look') {
  134. str = '查看' + str
  135. }
  136. let params = {
  137. type
  138. }
  139. if(type == 'update' || type == 'look') {
  140. params.id = row.id
  141. }
  142. this.$router.push({
  143. path: '/operateManager/questionOperation',
  144. query: params
  145. }, (router) => {
  146. router.meta.title = str;
  147. })
  148. },
  149. async onOperation(row, type) {
  150. let str = row.status ? '停用' : '启用'
  151. this.$confirm(`是否${str}该问卷?`, '提示', {
  152. confirmButtonText: '确定',
  153. cancelButtonText: '取消',
  154. type: 'warning'
  155. }).then(async () => {
  156. try {
  157. let status = row.status ? 0 : 1
  158. await questionnaireTopicUpdateStatus({ topicId: row.id, status: status })
  159. this.$message.success(str + '成功')
  160. this.getList()
  161. } catch {
  162. //
  163. }
  164. })
  165. },
  166. search() {
  167. this.pageInfo.page = 1;
  168. this.getList();
  169. },
  170. onReSet() {
  171. this.$refs['searchForm'].resetFields();
  172. this.search();
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. /deep/.el-button--primary {
  179. background: #14928a;
  180. border-color: #14928a;
  181. color: #fff;
  182. &:hover,
  183. &:active,
  184. &:focus {
  185. background: #14928a;
  186. border-color: #14928a;
  187. color: #fff;
  188. }
  189. }
  190. /deep/.el-date-editor.el-input {
  191. width: 100% !important;
  192. }
  193. /deep/.el-select {
  194. width: 98% !important;
  195. }
  196. </style>