modulePage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <!-- 业务模块 -->
  3. <div class="set-background">
  4. <div class="block">
  5. <el-form :model="moduleForm">
  6. <div class="set-head">
  7. 业务模块<el-input v-model="moduleForm.bizModuleName" clearable placeholder="请填写" style="margin-left:10px;width:18%;" /> &nbsp;&nbsp;
  8. 业务线<el-select v-model="moduleForm.bizId" placeholder="请选择" filterable clearable style="margin-left:10px;width:18%;" @change="choosePlatType()">
  9. <el-option v-for="item in bizData" :key="item.id" :label="item.bizName" :value="item.id" />
  10. </el-select>
  11. 平台类型<el-select v-model="moduleForm.platId" placeholder="请选择" filterable clearable style="margin-left:10px;width:18%;">
  12. <el-option v-for="item in platData1" :key="item.id" :label="item.platName" :value="item.id" />
  13. </el-select>
  14. <div style="float:right">
  15. <el-button type="primary" @click="queryModuleList(moduleForm)">查询</el-button>
  16. <el-button type="primary" plain @click="handleaddModule()">新增</el-button>
  17. </div>
  18. </div>
  19. </el-form>
  20. <div class="set-locate">
  21. <el-table :key="tableKey" :data="moduletData" fit highlight-current-row style="width: 100%;" border :header-cell-style="{background:'#F0F2F4',color:'#606266'}">
  22. <el-table-column label="序号" prop="id" min-width="40px" align="center"><template slot-scope="scope"><span>{{ scope.row.id }}</span></template> </el-table-column>
  23. <el-table-column label="业务模块" prop="bizModuleName" align="center" min-width="100">
  24. <template slot-scope="scope"><a href="javascript:void(0)" style="color:#20a0ff">{{ scope.row.bizModuleName }}</a></template>
  25. </el-table-column>
  26. <el-table-column label="平台类型" prop="platName" min-width="70px" align="center"><template slot-scope="scope"><span>{{ scope.row.platName }}</span></template> </el-table-column>
  27. <el-table-column label="业务线" prop="bizName" min-width="70px" align="center"><template slot-scope="scope"><span>{{ scope.row.bizName }}</span></template> </el-table-column>
  28. <el-table-column label="端类型" prop="clientType" min-width="120px" align="center"><template slot-scope="{row}"><span>{{ statusMaps.get(row.clientType) }}</span></template> </el-table-column>
  29. <el-table-column label="操作人" prop="modifier" min-width="70px" align="center"><template slot-scope="scope"><span>{{ scope.row.modifier }}</span></template> </el-table-column>
  30. <el-table-column label="操作" align="center" min-width="150px" class-name="small-padding fixed-width">
  31. <template slot-scope="{row}">
  32. <el-button type="primary" size="mini" @click="handelEditModule(row)">编辑</el-button>
  33. <el-button type="danger" size="mini" @click="handelDeleteModule(row)">删除</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <el-dialog :title="titleName" width="40%" :visible.sync="dialogFormVisible">
  38. <div style="margin-left:30px">
  39. <el-form ref="addModuleForms" :rules="addModuleDataRules" :model="addModuleForm">
  40. <el-form-item label="业务模块" prop="bizModuleName">
  41. <el-input v-model="addModuleForm.bizModuleName" placeholder="请填写" style="margin-left:7px;width:60%;" />
  42. </el-form-item>
  43. <el-form-item label="业务线" prop="bizId">
  44. <el-select v-model="addModuleForm.bizId" placeholder="请选择" filterable clearable style="margin-left:20px;width:60%;" @change="getPlatType()">
  45. <el-option v-for="item in bizData" :key="item.id" :label="item.bizName" :value="item.id" />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item label="平台类型" prop="platId">
  49. <el-select v-model="addModuleForm.platId" placeholder="请选择" filterable clearable style="margin-left:7px;width:60%;" @change="changePlat()">
  50. <el-option v-for="item in platData" :key="item.id" :label="item.platName" :value="item.id" />
  51. </el-select>
  52. </el-form-item>
  53. </el-form>
  54. </div>
  55. <div align="center" style="margin-top:18px">
  56. <el-button type="info" plain size="mini" @click="dialogFormVisible=false">取消</el-button>
  57. <el-button type="primary" size="mini" @click="titleName === '新增' ? addModuleType(addModuleForm) :editModuleType(addModuleForm)">确定</el-button>
  58. </div>
  59. <div style="margin-top:6%" />
  60. </el-dialog>
  61. <el-dialog :visible.sync="dialogDeleteVisible" width="30%">
  62. <div align="center" style="margin-top:-6%">
  63. <b>确定要删除该业务模块吗?</b>
  64. </div>
  65. <div align="center" style="margin-top:38px">
  66. <el-button type="primary" size="mini" @click="deleteModuleType()">确定</el-button>
  67. <el-button type="danger" size="mini" @click="dialogDeleteVisible=false">取消</el-button>
  68. </div>
  69. <div style="margin-top:4%" />
  70. </el-dialog>
  71. <div>
  72. <el-pagination style="margin-top:30px;" align="center" :current-page="curIndex" :page-sizes="[5, 10, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  73. </div>
  74. </div>
  75. </div>
  76. </div></template>
  77. <script>
  78. import { addBizModule, updateBizModule, deleteBizModule, queryBizModuleList, queryBizTypeList, queryPlatFormTypeList } from '@/api/modulePage'
  79. import waves from '@/directive/waves' // waves directive
  80. var envSelections = []
  81. var consumerSelections = []
  82. export default {
  83. name: 'ModulePage',
  84. // components: { Pagination },
  85. directives: { waves },
  86. filters: {
  87. statusFilter(status) {
  88. const statusMap = {
  89. 1: 'success',
  90. draft: 'info',
  91. 0: 'danger'
  92. }
  93. return statusMap[status]
  94. }
  95. },
  96. data() {
  97. return {
  98. userInformation: localStorage.getItem('username'),
  99. userName: localStorage.getItem('realname'),
  100. statusMaps: new Map([[1, '服务端 '], [2, '客户端']]),
  101. clientOptions: [{
  102. value: 1,
  103. label: '服务端'
  104. }, {
  105. value: 2,
  106. label: '客户端'
  107. }, {
  108. value: 0,
  109. label: '默认选项'
  110. }],
  111. userData: '',
  112. envSelections,
  113. addModuleForm: {},
  114. consumerSelections,
  115. bizData: [],
  116. total: 0,
  117. titleName: '',
  118. bizForm: {
  119. bizName: ''
  120. },
  121. moduleForm: {
  122. platId: '',
  123. bizId: '',
  124. bizModuleName: ''
  125. },
  126. platData: [],
  127. platData1: [],
  128. platType: {},
  129. deleteData: {},
  130. moduletData: [],
  131. addModuleData: {},
  132. currentBizData: [],
  133. tableKey: 0,
  134. curIndex: 0,
  135. pageSize: 10,
  136. listLoading: true,
  137. dialogFormVisible: false,
  138. dialogDeleteVisible: false,
  139. // dialogName: '业务线名称',
  140. addModuleDataRules: {
  141. bizModuleName: [{ required: true, message: '业务类型不能为空', trigger: 'change' }],
  142. platId: [{ required: true, message: '平台类型不能为空', trigger: 'change' }],
  143. bizId: [{ required: true, message: '业务线不能为空', trigger: 'change' }]
  144. }
  145. }
  146. },
  147. created() {
  148. this.getBizList()
  149. // this.getPlatList()
  150. this.getList()
  151. },
  152. methods: {
  153. // 获得biztype
  154. getBizList() {
  155. this.bizForm.bizName = ''
  156. this.bizForm.curIndex = this.curIndex - 1
  157. queryBizTypeList(this.bizForm).then(response => {
  158. if (response.code === 200) {
  159. this.bizData = response.data.list
  160. } else {
  161. this.errorFun()
  162. }
  163. })
  164. },
  165. // 获取平台类型
  166. choosePlatType() {
  167. // this.listLoading = true
  168. this.indexPage = {
  169. bizId: this.moduleForm.bizId,
  170. pageSize: this.pageSize,
  171. curIndex: this.curIndex - 1
  172. }
  173. queryPlatFormTypeList(this.indexPage).then(response => {
  174. this.platData1 = response.data.list
  175. this.$set(this.moduleForm, 'platId', '')
  176. this.total = response.data.total
  177. this.listLoading = false
  178. })
  179. },
  180. // 新增获取平台类型
  181. getPlatType() {
  182. // this.listLoading = true
  183. this.indexPage = {
  184. bizId: this.addModuleForm.bizId,
  185. pageSize: this.pageSize,
  186. curIndex: this.curIndex - 1
  187. }
  188. queryPlatFormTypeList(this.indexPage).then(response => {
  189. this.platData = response.data.list
  190. // this.$set(this.addModuleForm, 'platId', '')
  191. // this.total = response.data.total
  192. this.listLoading = false
  193. })
  194. },
  195. changePlat() {
  196. this.addData = { id: this.addModuleForm.platId }
  197. queryPlatFormTypeList(this.addData).then(response => {
  198. this.platType = response.data.list
  199. console.log(this.platType)
  200. console.log(this.platType[0].bizId)
  201. this.total = 30
  202. this.listLoading = false
  203. })
  204. },
  205. // 新增平台类型
  206. handleaddModule() {
  207. this.titleName = '新增'
  208. this.dialogFormVisible = true
  209. this.$refs.addModuleForms.resetFields()
  210. this.$set(this.addModuleForm, 'bizModuleName', '')
  211. this.$set(this.addModuleForm, 'platId', '')
  212. this.$set(this.addModuleForm, 'bizId', '')
  213. this.addModuleForm = {}
  214. },
  215. addModuleType(ele) {
  216. this.$refs['addModuleForms'].validate((valid) => {
  217. if (valid) {
  218. this.addModuleForm = ele
  219. this.addModuleForm.bizModuleName = ele.bizModuleName
  220. this.addModuleForm.platId = ele.platId
  221. this.addModuleForm.bizId = ele.bizId
  222. this.addModuleForm.clientType = this.platType[0].clientType
  223. this.addModuleForm.creator = this.userInformation
  224. this.addModuleForm.modifier = this.userInformation
  225. addBizModule(this.addModuleForm).then(response => {
  226. console.log(response)
  227. if (response.code === 200) {
  228. this.getList()
  229. this.successFun()
  230. this.dialogFormVisible = false
  231. } else {
  232. this.errorFun()
  233. }
  234. })
  235. }
  236. })
  237. },
  238. // 进首页
  239. getList() {
  240. // this.listLoading = true
  241. this.indexPage = {
  242. pageSize: this.pageSize,
  243. curIndex: this.curIndex - 1
  244. }
  245. queryBizModuleList(this.indexPage).then(response => {
  246. this.moduletData = response.data.list
  247. this.total = response.data.total
  248. this.listLoading = false
  249. })
  250. },
  251. // 查看
  252. queryModuleList(ele) {
  253. this.moduleForm.bizModuleName = ele.bizModuleName
  254. this.moduleForm.bizId = ele.bizId
  255. this.moduleForm.platId = ele.platId
  256. // this.bizForm.pageSize = this.pageSize
  257. // this.platForm.curIndex = this.curIndex - 1
  258. // this.listLoading = true
  259. queryBizModuleList(this.moduleForm).then(response => {
  260. if (response.code === 200) {
  261. // this.getMyDevicesList()
  262. this.moduletData = response.data.list
  263. this.total = response.data.total
  264. this.dialogFormVisible = false
  265. // this.listLoading = false
  266. } else {
  267. this.errorFun()
  268. }
  269. })
  270. },
  271. // 删除
  272. handelDeleteModule(ele) {
  273. this.dialogDeleteVisible = true
  274. this.addModuleForm = ele
  275. },
  276. deleteModuleType() {
  277. var bizModuleIds = [this.addModuleForm.id]
  278. this.deleteData.modifier = this.userInformation
  279. this.deleteData.bizModuleIds = bizModuleIds
  280. deleteBizModule(this.deleteData).then(response => {
  281. if (response.code === 200) {
  282. this.successFun()
  283. this.dialogDeleteVisible = false
  284. this.getList()
  285. this.bizData = response.data.list
  286. } else {
  287. this.errorFun()
  288. // this.dialogDeleteVisible = false
  289. }
  290. })
  291. },
  292. // 编辑
  293. handelEditModule(ele) {
  294. // 不能直接赋值变量,使用Object.assign复制一级属性(注意Object.assign不算完全的深拷贝)
  295. this.addModuleForm = Object.assign({}, ele)
  296. // this.addModuleForm = JSON.parse(JSON.stringify(ele))
  297. this.titleName = '编辑'
  298. this.getPlatType()
  299. this.dialogFormVisible = true
  300. this.$refs.addModuleForms.resetFields()
  301. this.$set(this.platData, [])
  302. console.log(ele)
  303. },
  304. editModuleType(ele) {
  305. this.$refs['addModuleForms'].validate((valid) => {
  306. if (valid) {
  307. var myDate = new Date()
  308. this.addModuleForm = ele
  309. this.addModuleForm.bizModuleName = ele.bizModuleName
  310. this.addModuleForm.platId = ele.platId
  311. // this.addModuleForm.platName = this.platData.filter((value) => value.code === ele.platId)
  312. this.addModuleForm.modifyTime = myDate
  313. this.addModuleForm.modifier = this.userInformation
  314. // this.bizTypeInfo = { bizTypeInfo: this.addBizData }
  315. updateBizModule(this.addModuleForm).then(response => {
  316. this.$set(this.platData, [])
  317. console.log(response)
  318. if (response.code === 200) {
  319. this.getList()
  320. this.successFun()
  321. this.dialogFormVisible = false
  322. } else {
  323. this.errorFun()
  324. }
  325. })
  326. }
  327. })
  328. },
  329. handleSizeChange(size) {
  330. this.pageSize = size
  331. this.getList()
  332. },
  333. handleCurrentChange(curIndex) {
  334. this.curIndex = curIndex
  335. this.getList()
  336. },
  337. clearValidate(formName) {
  338. this.$refs[formName].clearValidate()
  339. },
  340. successFun() {
  341. this.$notify({ title: 'Success', message: 'Created Successfully', type: 'success', duration: 5000 })
  342. },
  343. errorFun() {
  344. this.$notify({ title: 'Failed', message: 'Created Failed', type: 'error', duration: 5000 })
  345. }
  346. }
  347. }
  348. </script>
  349. <style lang="stylus" scoped>
  350. .set-background
  351. background-color #F1F4F7
  352. display flex
  353. justify-content center
  354. min-width 700px
  355. .setPercent >>> .el-dialog__body
  356. width 100%
  357. .block
  358. background-color rgba(255,255,255,1)
  359. box-shadow 0px 0px 11px 0px rgba(238,240,245,1)
  360. border-radius 7px
  361. width 93%
  362. margin 25px 0
  363. padding 20px
  364. min-height calc(100vh - 100px)
  365. .set-head
  366. font-size 13px
  367. width 100%
  368. color #333B4A
  369. white-space nowrap
  370. .set-dialogfont
  371. font-size 13px
  372. .set-dialogfont >>> .el-input
  373. width 70%
  374. // .set-between
  375. // display flex
  376. // .set-between >>> .el-button
  377. // height 40px
  378. .set-locate
  379. margin-top 25px
  380. // border-bottom 1px solid #BFC6DC
  381. // border-left 1px solid #BFC6DC
  382. // border-top 1px solid #BFC6DC
  383. // border-right 1px solid #BFC6DC
  384. </style>