subProjectManage.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="form-wrap">
  3. <el-form
  4. class="searchBox"
  5. ref="form"
  6. :model="form"
  7. :inline="true"
  8. label-width="140px">
  9. <div class="block-title">
  10. 查询条件
  11. </div>
  12. <el-form-item
  13. label="子项名称"
  14. prop="name">
  15. <el-input v-model="form.name" clearable></el-input>
  16. </el-form-item>
  17. <div class="btn-wrap">
  18. <el-button
  19. @click="reset">
  20. 重置
  21. </el-button>
  22. <el-button
  23. type="primary"
  24. @click="getList(true)">
  25. 搜索
  26. </el-button>
  27. <el-button
  28. type="primary"
  29. @click="openAddDialog(true)">
  30. 新增子项
  31. </el-button>
  32. </div>
  33. </el-form>
  34. <div class="tableBox">
  35. <div class="block-title">
  36. 子项目列表
  37. </div>
  38. <el-table
  39. border
  40. v-loading="loading"
  41. :data="tableData">
  42. <el-table-column
  43. prop="name"
  44. label="子项名称">
  45. </el-table-column>
  46. <el-table-column
  47. prop="adminIds"
  48. label="管理员">
  49. <template slot-scope="scope">
  50. {{ getAdminName(scope.row.adminIds) }}
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. prop="ticketTypeIds"
  55. label="票种">
  56. <template slot-scope="scope">
  57. {{ getTicketTypeNames(scope.row.ticketTypeIds) }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. width="150px"
  62. label="操作">
  63. <template slot-scope="scope">
  64. <el-link
  65. type="primary"
  66. @click="openEditDialog(scope.row)"
  67. >
  68. 编辑
  69. </el-link>
  70. <el-link
  71. type="primary"
  72. @click="deleteItem(scope.row)">
  73. 删除
  74. </el-link>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <el-pagination
  79. background
  80. :page-size="10"
  81. layout="prev, pager, next, total"
  82. :current-page.sync="form.pageNum"
  83. @current-change="getList()"
  84. :total="total"
  85. >
  86. </el-pagination>
  87. </div>
  88. <!-- 弹框 -->
  89. <ElDialog
  90. :title="`${currentItem.id ? '编辑' : '新增'}子项`"
  91. width="500px"
  92. v-model="dialogVisible"
  93. >
  94. <el-form
  95. inline
  96. :model="currentItem"
  97. ref="form"
  98. class="form-wrap"
  99. label-width="150px"
  100. style="margin-top: 20px">
  101. <el-form-item
  102. label="子项名称"
  103. verify
  104. prop="name">
  105. <el-input v-model="currentItem.name"></el-input>
  106. </el-form-item>
  107. <el-form-item
  108. label="管理员"
  109. v-if="currentItem.id"
  110. prop="adminIds">
  111. <el-select
  112. multiple
  113. clearable
  114. v-model="currentItem.adminIds">
  115. <el-option
  116. v-for="item in adminList"
  117. :key="item.id"
  118. :value="item.id"
  119. :label="item.loginName">
  120. </el-option>
  121. </el-select>
  122. </el-form-item>
  123. <el-form-item
  124. label="票种"
  125. v-if="currentItem.id"
  126. prop="ticketTypeIds">
  127. <el-select
  128. multiple
  129. clearable
  130. v-model="currentItem.ticketTypeIds">
  131. <el-option
  132. v-for="item in ticketTypeList"
  133. :key="item.id"
  134. :value="item.id"
  135. :label="item.name">
  136. </el-option>
  137. </el-select>
  138. </el-form-item>
  139. </el-form>
  140. <div style="margin: 20px; float: right;">
  141. <el-button @click="dialogVisible = false">取消</el-button>
  142. <el-button type="primary" @click="confirmOptItem">确定</el-button>
  143. </div>
  144. </ElDialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { getSubProjectList, addSubProject, updateSubProject, deleteSubProject } from '@/api/checker'
  149. import { getAccountList } from '@/api/systemSetting/account'
  150. import { getTicketTypeList } from '@/api/ticketType'
  151. import ElDialog from '@/components/Dialog'
  152. export default {
  153. data () {
  154. return {
  155. form: {
  156. name: '', // 名称
  157. pageNum: 1,
  158. pageSize: 10
  159. },
  160. loading: false,
  161. tableData: [],
  162. total: 0,
  163. dialogVisible: false,
  164. configDialogVisible: false,
  165. currentItem: {},
  166. adminList: [],
  167. ticketTypeList: []
  168. }
  169. },
  170. computed: {
  171. scenicList () {
  172. return this.$store.state.app.scenicList
  173. }
  174. },
  175. created () {
  176. this.getList()
  177. getAccountList({ pageSize: -1, pageNum: 1 }).then(res => {
  178. this.adminList = res.data.records || []
  179. })
  180. getTicketTypeList({ pageSize: -1, pageNum: 1 }).then(res => {
  181. this.ticketTypeList = res.data.records || []
  182. })
  183. },
  184. components: {
  185. ElDialog
  186. },
  187. methods: {
  188. reset () {
  189. this.$refs.form.resetFields()
  190. },
  191. // 获取通道列表
  192. getList (goFirst) {
  193. let params = { ...this.form }
  194. goFirst && (params.pageNum = 1)
  195. this.loading = true
  196. getSubProjectList(params).then(res => {
  197. const list = res.data?.records || []
  198. this.total = res.data?.total || 0
  199. this.tableData = list
  200. this.loading = false
  201. })
  202. },
  203. // 打开弹框
  204. openAddDialog () {
  205. this.currentItem = {
  206. id: '',
  207. name: ''
  208. }
  209. this.dialogVisible = true
  210. },
  211. openEditDialog (item) {
  212. this.currentItem = {
  213. id: item.id,
  214. name: item.name,
  215. adminIds: item.adminIds || [],
  216. ticketTypeIds: item.ticketTypeIds || []
  217. }
  218. this.dialogVisible = true
  219. },
  220. deleteItem (data) {
  221. this.$confirm('确定删除子项吗?', '提示', {
  222. confirmButtonText: '确定',
  223. cancelButtonText: '取消',
  224. type: 'warning'
  225. }).then(() => {
  226. deleteSubProject(data.id).then(res => {
  227. this.$message.success('操作成功')
  228. this.getList()
  229. })
  230. }).catch(() => {})
  231. },
  232. confirmOptItem () {
  233. const opt = this.currentItem.id ? updateSubProject : addSubProject
  234. opt(this.currentItem).then(res => {
  235. this.$message.success('操作成功')
  236. this.dialogVisible = false
  237. this.getList()
  238. })
  239. },
  240. getAdminName (ids) {
  241. if (!ids) return ''
  242. const names = this.adminList.filter(item => ids.includes(item.id)).map(item => item.loginName)
  243. return names.join(',')
  244. },
  245. getTicketTypeNames (ids) {
  246. if (!ids) return ''
  247. const names = this.ticketTypeList.filter(item => ids.includes(item.id)).map(item => item.name)
  248. return names.join(',')
  249. }
  250. }
  251. }
  252. </script>
  253. <style scoped>
  254. </style>