index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="admin-apply">
  3. <el-form :inline="true">
  4. <el-form-item>
  5. <el-input v-model="queryParams.name" size="small" placeholder="请输入"></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="" size="small" @click="getList">查询</el-button>
  9. <el-button type="primary" size="small" @click="handleAdd(0)">新增</el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-table
  13. :row-key="getRowKeys"
  14. v-loading="loading"
  15. :data="tableData"
  16. header-row-class-name="custom-table-header"
  17. :expand-row-keys="expands"
  18. @expand-change="expandChange"
  19. :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
  20. >
  21. <el-table-column type="expand">
  22. <template slot-scope="scope" style="width:80%">
  23. <function-list :applyId="scope.row.id"></function-list>
  24. </template>
  25. </el-table-column>
  26. <el-table-column label="应用名称" align="" show-overflow-tooltip>
  27. <template slot-scope="scope">
  28. <span class="details">{{scope.row.name}}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column prop="describe" label="应用描述" align="center" show-overflow-tooltip></el-table-column>
  32. <el-table-column prop="createUserName" label="创建人" align="center" show-overflow-tooltip></el-table-column>
  33. <el-table-column label="操作" align="center" width="150">
  34. <template slot-scope="scope">
  35. <el-dropdown split-button type="primary" size="small" @click="handleEdit(scope.row)" >
  36. 编辑
  37. <el-dropdown-menu slot="dropdown" class="text-align_center">
  38. <el-dropdown-item @click.native="handleDetails(scope.row)">详情</el-dropdown-item>
  39. <el-dropdown-item class="color-red" @click.native="handleDelete(scope.row)" divided>删除</el-dropdown-item>
  40. </el-dropdown-menu>
  41. </el-dropdown>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div class="pagination">
  46. <el-pagination :current-page.sync="queryParams.current" :page-size="queryParams.size" :total="total" @current-change="handleCurrentChange" layout="total, prev, pager, next, jumper" background></el-pagination>
  47. </div>
  48. <el-dialog :title="title" :visible.sync="visible" width="500px" :before-close="close">
  49. <el-form v-if="visible" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" label-position="left">
  50. <el-form-item label="应用名称" prop="name">
  51. <el-input v-model="ruleForm.name" placeholder="请输入应用名称"></el-input>
  52. </el-form-item>
  53. <el-form-item label="应用描述" prop="describe">
  54. <el-input v-model="ruleForm.describe" placeholder="请输入" type="textarea" maxlength="100" show-word-limit></el-input>
  55. </el-form-item>
  56. </el-form>
  57. <div slot="footer" class="dialog-footer">
  58. <el-button @click="close">取 消</el-button>
  59. <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
  60. </div>
  61. </el-dialog>
  62. <el-dialog :title="title" :visible.sync="showvisible" width="700px" class="my-dialog-name" contentStyle="width:400px;" :before-close="close" v-if="ruleForm.apply!=null">
  63. <el-form label-position="left" class="demo-table-expand" label-width="80px">
  64. <el-form-item label="应用名称 :">
  65. <span>{{ruleForm.apply.name}}</span>
  66. </el-form-item>
  67. <el-form-item label="应用描述 :">
  68. <span>{{ruleForm.apply.describe}}</span>
  69. </el-form-item>
  70. <el-form-item label="创建人 :">
  71. <span>{{ruleForm.apply.createUserName}}</span>
  72. </el-form-item>
  73. <el-form-item label="租户列表" class="list">
  74. </el-form-item>
  75. </el-form>
  76. <el-table :data="ruleForm.tenantVOList" header-row-class-name="custom-table-header" max-height="250" border>
  77. <!-- <el-table-column type="index" label="#" width="55" align="center"></el-table-column> -->
  78. <el-table-column prop="name" label="租户名称" align="center" show-overflow-tooltip></el-table-column>
  79. <el-table-column prop="contacts" label="联系人" align="center" show-overflow-tooltip></el-table-column>
  80. <el-table-column prop="address" label="联系人地址" align="center" show-overflow-tooltip></el-table-column>
  81. <el-table-column prop="type" label="类型" align="center" show-overflow-tooltip></el-table-column>
  82. <el-table-column label="是否启用" align="center" show-overflow-tooltip>
  83. <template slot-scope="scope">
  84. <span v-if="scope.row.state==0">否</span>
  85. <span v-if="scope.row.state==1">是</span>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. import Treeselect from '@riophae/vue-treeselect'
  94. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  95. import FunctionList from '../function/index.vue'
  96. export default {
  97. components: {
  98. Treeselect,
  99. FunctionList
  100. },
  101. data() {
  102. return {
  103. getRowKeys(row){
  104. return row.id
  105. },
  106. visible: false,
  107. showvisible:false,
  108. loading: false,
  109. btnLoading: false,
  110. total: 0,
  111. tableData: [],
  112. title: '',
  113. expands:[],
  114. queryParams: {
  115. size: 10,
  116. current: 1,
  117. name: ''
  118. },
  119. ruleForm: {},
  120. rules: {
  121. name: [{ required: true, message: '请输入应用名称', trigger: 'blur' },],
  122. describe: [{ required: true, message: '请输入描述', trigger: 'blur' },],
  123. },
  124. }
  125. },
  126. computed: {
  127. userinfo() {
  128. return this.$store.state.admin.userinfo
  129. }
  130. },
  131. mounted() {
  132. this.getList()
  133. },
  134. methods: {
  135. expandChange(row,expandedRows) {
  136. let that=this
  137. console.log(expandedRows);
  138. if (expandedRows.length) {
  139. that.expands = []
  140. if (row) {
  141. that.expands.push(row.id)
  142. }
  143. } else {
  144. that.expands = []
  145. }
  146. },
  147. normalizer(node) {
  148. return {
  149. id: node.id,
  150. label: node.name,
  151. }
  152. },
  153. handleAdd(parentId) {
  154. this.title = '新增应用'
  155. this.visible = true
  156. this.ruleForm = {
  157. // sort: 0,
  158. // parentId: parentId
  159. }
  160. },
  161. handleEdit(row) {
  162. this.title = '编辑应用'
  163. this.visible = true
  164. this.ruleForm = { ...row }
  165. },
  166. handleDetails(row){
  167. this.title = '应用详情'
  168. this.showvisible = true
  169. this.$api.getAllTenantByApplicationId({id:row.id}).then(response=>{
  170. console.log(response)
  171. this.ruleForm = response.data
  172. this.ruleForm.apply={...row}
  173. })
  174. },
  175. handleCurrentChange(val) {
  176. this.queryParams.current = val;
  177. this.getList();
  178. },
  179. close() {
  180. this.visible = false
  181. this.showvisible = false
  182. },
  183. getList() {
  184. this.loading = true
  185. this.$api.getApplyList(this.queryParams).then(response => {
  186. this.tableData = response.data
  187. this.total = response.pageColumn.total
  188. this.loading = false
  189. }).catch(error => {
  190. this.loading = false
  191. })
  192. },
  193. submit() {
  194. this.$refs.ruleForm.validate((valid) => {
  195. if (valid) {
  196. this.btnLoading = true
  197. if (this.ruleForm.id) {
  198. this.$api.editApply(this.ruleForm).then(response => {
  199. this.$message.success('编辑成功')
  200. this.btnLoading = false
  201. this.getList()
  202. this.close()
  203. }).catch(error => {
  204. this.btnLoading = false
  205. })
  206. } else {
  207. this.ruleForm.tenant=this.userinfo.tenantId
  208. this.$api.addApply(this.ruleForm).then(response => {
  209. console.log(2,response)
  210. this.$message.success('新增成功')
  211. this.btnLoading = false
  212. this.getList()
  213. this.close()
  214. }).catch(error => {
  215. this.btnLoading = false
  216. })
  217. }
  218. } else {
  219. console.log('error submit!!');
  220. return false;
  221. }
  222. });
  223. },
  224. handleDelete(row) {
  225. this.$confirm('确认删除本条数据吗?', '提示', {
  226. confirmButtonText: '确定',
  227. cancelButtonText: '取消',
  228. type: 'warning'
  229. }).then(() => {
  230. this.loading = true
  231. this.$api.deleteApply({ id: row.id }).then(response => {
  232. this.$message.success('删除成功')
  233. this.loading = false
  234. this.getList()
  235. }).catch(error => {
  236. this.loading = false
  237. })
  238. })
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. .my-dialog-name{
  245. .el-dialog__body{
  246. padding-top:0
  247. }
  248. }
  249. .list .el-form-item__label{
  250. font-weight: 900;
  251. }
  252. </style>
  253. <style lang="scss" scoped>
  254. .admin-apply {
  255. }
  256. // .details:hover{
  257. // border-bottom: 1px solid black;
  258. // cursor: pointer;
  259. // }
  260. .demo-table-expand {
  261. font-size: 0;
  262. }
  263. .demo-table-expand label {
  264. width: 90px;
  265. color: #99a9bf;
  266. }
  267. .demo-table-expand .el-form-item {
  268. margin-right: 0;
  269. margin-bottom: 0;
  270. width: 50%;
  271. }
  272. </style>