subProjectManage.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="form-wrap">
  3. <el-form
  4. class="search-box"
  5. ref="form"
  6. :model="form"
  7. :inline="true"
  8. >
  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="table-box">
  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. {{ getNameList(scope.row.admins, 'loginName') }}
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. prop="ticketTypeIds"
  55. label="票种">
  56. <template slot-scope="scope">
  57. {{ getNameList(scope.row.ticketTypes) }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column
  61. prop="scenicIds"
  62. label="景区">
  63. <template slot-scope="scope">
  64. {{ getNameList(scope.row.scenicList) }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. prop="payChannelIds"
  69. label="支付渠道">
  70. <template slot-scope="scope">
  71. {{ getNameList(scope.row.payChannelList) }}
  72. </template>
  73. </el-table-column>
  74. <el-table-column
  75. prop="checkerIds"
  76. label="检票设备">
  77. <template slot-scope="scope">
  78. {{ getNameList(scope.row.checkerList) }}
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. width="150px"
  83. label="操作">
  84. <template slot-scope="scope">
  85. <el-link
  86. type="primary"
  87. @click="openEditDialog(scope.row)"
  88. >
  89. 编辑
  90. </el-link>
  91. <el-link
  92. type="primary"
  93. @click="deleteItem(scope.row)">
  94. 删除
  95. </el-link>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <el-pagination
  100. background
  101. layout="total, sizes, prev, pager, next, jumper"
  102. :current-page.sync="form.pageNum"
  103. :page-sizes="[10, 20, 50, 100]"
  104. :page-size="form.pageSize"
  105. @size-change="handleSizeChange"
  106. @current-change="getList()"
  107. :total="total"
  108. >
  109. </el-pagination>
  110. </div>
  111. <!-- 弹框 -->
  112. <ElDialog
  113. :title="`${currentItem.id ? '编辑' : '新增'}子项`"
  114. width="500px"
  115. v-model="dialogVisible"
  116. >
  117. <el-form
  118. inline
  119. :model="currentItem"
  120. ref="form"
  121. class="form-wrap"
  122. label-width="150px"
  123. style="margin-top: 20px">
  124. <el-form-item
  125. label="数据权限名称"
  126. verify
  127. prop="name">
  128. <el-input v-model="currentItem.name"></el-input>
  129. </el-form-item>
  130. <el-form-item
  131. label="管理员"
  132. v-if="currentItem.id"
  133. prop="adminIds">
  134. <el-select
  135. multiple
  136. clearable
  137. v-model="currentItem.adminIds">
  138. <el-option
  139. v-for="item in adminList"
  140. :key="item.id"
  141. :value="item.id"
  142. :label="item.loginName">
  143. </el-option>
  144. </el-select>
  145. </el-form-item>
  146. <el-form-item
  147. label="票种"
  148. v-if="currentItem.id"
  149. prop="ticketTypeIds">
  150. <el-select
  151. multiple
  152. clearable
  153. v-model="currentItem.ticketTypeIds">
  154. <el-option
  155. v-for="item in ticketTypeList"
  156. :key="item.id"
  157. :value="item.id"
  158. :label="item.name">
  159. </el-option>
  160. </el-select>
  161. </el-form-item>
  162. <el-form-item
  163. label="景区"
  164. v-if="currentItem.id"
  165. prop="scenicIds">
  166. <el-select
  167. multiple
  168. clearable
  169. v-model="currentItem.scenicIds">
  170. <el-option
  171. v-for="item in scenicList"
  172. :key="item.id"
  173. :value="item.id"
  174. :label="item.name">
  175. </el-option>
  176. </el-select>
  177. </el-form-item>
  178. <el-form-item
  179. label="支付渠道"
  180. v-if="currentItem.id"
  181. prop="payChannelIds">
  182. <el-select
  183. multiple
  184. clearable
  185. v-model="currentItem.payChannelIds">
  186. <el-option
  187. v-for="item in payChannelList"
  188. :key="item.id"
  189. :value="item.id"
  190. :label="item.name">
  191. </el-option>
  192. </el-select>
  193. </el-form-item>
  194. <el-form-item
  195. label="检票设备"
  196. prop="checkerIds">
  197. <el-select
  198. v-model="currentItem.checkerIds"
  199. multiple
  200. clearable>
  201. <el-option
  202. v-for="item in deviceList"
  203. :key="item.id"
  204. :value="item.id"
  205. :label="item.name">
  206. </el-option>
  207. </el-select>
  208. </el-form-item>
  209. </el-form>
  210. <div style="margin: 20px; float: right;">
  211. <el-button @click="dialogVisible = false">取消</el-button>
  212. <el-button type="primary" @click="confirmOptItem">确定</el-button>
  213. </div>
  214. </ElDialog>
  215. </div>
  216. </template>
  217. <script>
  218. import { getSubProjectList, addSubProject, updateSubProject, deleteSubProject, getDeviceList } from '@/api/checker'
  219. import { getAccountList } from '@/api/systemSetting/account'
  220. import { getTicketTypeList, getScenic } from '@/api/ticketType'
  221. import { getPayChannel } from '@/api/payChannel'
  222. import ElDialog from '@/components/Dialog'
  223. export default {
  224. data () {
  225. return {
  226. form: {
  227. name: '', // 名称
  228. pageNum: 1,
  229. pageSize: 10
  230. },
  231. loading: false,
  232. tableData: [],
  233. total: 0,
  234. dialogVisible: false,
  235. configDialogVisible: false,
  236. currentItem: {},
  237. adminList: [],
  238. ticketTypeList: [],
  239. scenicList: [],
  240. payChannelList: [],
  241. deviceList: []
  242. }
  243. },
  244. created () {
  245. this.getList()
  246. getAccountList({ pageSize: -1, pageNum: 1 }).then(res => {
  247. this.adminList = res.data.records || []
  248. })
  249. getTicketTypeList({ pageSize: -1, pageNum: 1 }).then(res => {
  250. this.ticketTypeList = res.data.records || []
  251. })
  252. getScenic().then(res => {
  253. this.scenicList = res.data.records || []
  254. })
  255. getPayChannel({ pageSize: -1, pageNum: 1 }).then(res => {
  256. this.payChannelList = res.data.records || []
  257. })
  258. getDeviceList({ pageSize: -1, pageNum: 1 }).then(res => {
  259. this.deviceList = res.data.records || []
  260. })
  261. },
  262. components: {
  263. ElDialog
  264. },
  265. methods: {
  266. reset () {
  267. this.$refs.form.resetFields()
  268. },
  269. handleSizeChange (size) {
  270. this.form.pageSize = size
  271. this.getList()
  272. },
  273. // 获取通道列表
  274. getList (goFirst) {
  275. let params = { ...this.form }
  276. goFirst && (params.pageNum = 1)
  277. this.loading = true
  278. getSubProjectList(params).then(res => {
  279. const list = res.data?.records || []
  280. this.total = res.data?.total || 0
  281. this.tableData = list
  282. this.loading = false
  283. })
  284. },
  285. // 打开弹框
  286. openAddDialog () {
  287. this.currentItem = {
  288. id: '',
  289. name: ''
  290. }
  291. this.dialogVisible = true
  292. },
  293. openEditDialog (item) {
  294. this.currentItem = {
  295. id: item.id,
  296. name: item.name,
  297. adminIds: item.admins ? item.admins.map(adm => adm.id) || [] : [],
  298. ticketTypeIds: item.ticketTypes ? item.ticketTypes.map(tt => tt.id) || [] : [],
  299. scenicIds: item.scenicList ? item.scenicList.map(sc => sc.id) || [] : [],
  300. payChannelIds: item.payChannelList ? item.payChannelList.map(pc => pc.id) || [] : [],
  301. checkerIds: item.checkerList ? item.checkerList.map(ch => ch.id) || [] : []
  302. }
  303. this.dialogVisible = true
  304. },
  305. deleteItem (data) {
  306. this.$confirm('确定删除子项吗?', '提示', {
  307. confirmButtonText: '确定',
  308. cancelButtonText: '取消',
  309. type: 'warning'
  310. }).then(() => {
  311. deleteSubProject(data.id).then(res => {
  312. this.$message.success('操作成功')
  313. this.getList()
  314. })
  315. }).catch(() => {})
  316. },
  317. confirmOptItem () {
  318. const opt = this.currentItem.id ? updateSubProject : addSubProject
  319. opt(this.currentItem).then(res => {
  320. this.$message.success('操作成功')
  321. this.dialogVisible = false
  322. this.getList()
  323. })
  324. },
  325. getNameList (list, key = 'name') {
  326. if (!list) return ''
  327. return list.map(item => item[key]).join(',')
  328. }
  329. }
  330. }
  331. </script>
  332. <style scoped>
  333. </style>