approval.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <!-- -->
  2. <template>
  3. <div class=''>
  4. <el-breadcrumb class="divi2" separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  6. <el-breadcrumb-item>审批</el-breadcrumb-item>
  7. </el-breadcrumb>
  8. <el-divider class="divi"></el-divider>
  9. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  10. <el-form-item>
  11. <el-input v-model="dataForm.missName" placeholder="请输入算法名" clearable
  12. @keyup.enter.native="pageIndex = 1;getDataList()"></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button @click="pageIndex = 1;getDataList()">查询</el-button>
  16. </el-form-item>
  17. <el-form-item>
  18. <el-tag>筛选:</el-tag>
  19. <el-select v-model="classificationtag" clearable placeholder="类别" size="mini" style="width: 130px;"
  20. @change="pageIndex = 1;getDataList2()">
  21. <el-option v-for="data in classification" :key="data" :label="data" :value="data">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. </el-form>
  26. <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
  27. style="width: 100%;">
  28. <el-table-column type="selection" header-align="center" align="center" width="50">
  29. </el-table-column>
  30. <!-- <el-table-column prop="approvalId" header-align="center" align="center" width="80" label="审批ID">
  31. </el-table-column> -->
  32. <el-table-column label="序号" header-align="center" align="center" width="80" type="index" :index='(index)=>{return (index+1) + (this.pageIndex-1)*this.pageSize}'> </el-table-column>
  33. <el-table-column prop="missName" header-align="center" align="center" label="算法名称">
  34. </el-table-column>
  35. <el-table-column prop="approvalStatus" header-align="center" align="center" label="状态">
  36. <template slot-scope="scope">
  37. <el-tag v-if="scope.row.approvalStatus === 0" size="small">待审批</el-tag>
  38. <el-tag v-else-if="scope.row.approvalStatus === 1" size="small" type="success">已通过</el-tag>
  39. <el-tag v-else-if="scope.row.approvalStatus === -1" size="small" type="danger">已拒绝</el-tag>
  40. <el-tag v-else size="small" type="success">已结束</el-tag>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="categoryName" header-align="center" align="center" label="分类">
  44. </el-table-column>
  45. <el-table-column prop="username" header-align="center" align="center" label="申请人">
  46. </el-table-column>
  47. <el-table-column prop="applyTime" header-align="center" align="center" width="180" label="申请时间"
  48. :formatter="applyTimeFormat">
  49. </el-table-column>
  50. <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
  51. <template slot-scope="scope">
  52. <el-button type="text" size="small" @click="approve(scope.row.approvalId)" :disabled="scope.row.approvalStatus!=0?true:false"
  53. >通过
  54. </el-button>
  55. <el-button type="text" size="small" :disabled="scope.row.approvalStatus!=0?true:false"
  56. @click="refuse(scope.row.approvalId)">
  57. 拒绝</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
  62. :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
  63. layout="total, sizes, prev, pager, next, jumper">
  64. </el-pagination>
  65. <PythonKafkaTmp v-if="pythonKafkaVisible" ref="pythonKafkaTmp" @refreshDataList="getDataList"></PythonKafkaTmp>
  66. </div>
  67. </template>
  68. <script>
  69. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  70. //例如:import 《组件名称》 from '《组件路径》';
  71. import PythonKafkaTmp from "../alg/python-kafka-tmp.vue";
  72. import { MessageBox } from 'element-ui'
  73. import { Message } from "element-ui"
  74. export default {
  75. //import引入的组件需要注入到对象中才能使用
  76. data() {
  77. return {
  78. dataForm: {
  79. missName: "",
  80. },
  81. dataList: [],
  82. pageIndex: 1,
  83. pageSize: 10,
  84. totalPage: 0,
  85. dataListLoading: false,
  86. dataListSelections: [],
  87. addOrUpdateVisible: false,
  88. pythonKafkaVisible: false,
  89. classificationtag: "",
  90. classification: [],
  91. form: null,
  92. };
  93. },
  94. components: {
  95. PythonKafkaTmp
  96. },
  97. activated() {
  98. this.getDataList();
  99. },
  100. methods: {
  101. // 获取数据列表
  102. getDataList() {
  103. this.dataListLoading = true;
  104. this.classificationtag = '';
  105. this.form = null;
  106. this.$http({
  107. url: this.$http.adornUrl("/category/select"),
  108. method: "get",
  109. }).then(({ data }) => {
  110. this.classification = this.unique(data.list);
  111. });
  112. this.$http({
  113. url: this.$http.adornUrl("/algs/approval/list"),
  114. method: "get",
  115. params: this.$http.adornParams({
  116. page: this.pageIndex,
  117. limit: this.pageSize,
  118. modelName: this.dataForm.modelName,
  119. }),
  120. }).then(({ data }) => {
  121. if (data && data.code === 0) {
  122. this.dataList = data.page.list;
  123. this.totalPage = data.page.totalCount;
  124. this.statusunique = this.unique(data.page.list);
  125. } else {
  126. this.dataList = [];
  127. this.totalPage = 0;
  128. }
  129. this.dataListLoading = false;
  130. });
  131. },
  132. //筛选查询
  133. getDataList2() {
  134. this.dataListLoading = true;
  135. if(this.classificationtag===''){
  136. this.classificationtag=null;
  137. }
  138. this.$http({
  139. url: this.$http.adornUrl("/algs/approval/list"),
  140. method: "get",
  141. params: this.$http.adornParams({
  142. page: this.pageIndex,
  143. limit: this.pageSize,
  144. misslName: this.dataForm.missName,
  145. // 增加status参数用于筛选查询
  146. classificationtag: this.classificationtag,
  147. }),
  148. }).then(({ data }) => {
  149. if (data && data.code === 0) {
  150. this.dataList = data.page.list;
  151. this.totalPage = data.page.totalCount;
  152. } else {
  153. this.dataList = [];
  154. this.totalPage = 0;
  155. }
  156. this.dataListLoading = false;
  157. });
  158. },
  159. onDialogClose(){
  160. console.log("查看完成");
  161. },
  162. stateFormat(row, column) {
  163. if (row.form === 1) {
  164. return "传统算法";
  165. } else {
  166. return "智能算法";
  167. }
  168. },
  169. applyTimeFormat(row, column){
  170. if (row.applyTime === null) {
  171. return "-";
  172. } else{
  173. return row.applyTime;
  174. }
  175. },
  176. //通过申请
  177. approve(id){
  178. MessageBox.confirm('是否通过该发布申请?', '提示', {
  179. confirmButtonText: '确定',
  180. cancelButtonText: '取消',
  181. type: 'warning'
  182. }).then(() => {
  183. this.$http({
  184. url:this.$http.adornUrl('/algs/approval/approve'),
  185. method:'get',
  186. params:this.$http.adornParams({
  187. approvalId:id
  188. }),
  189. }).then(({data})=>{
  190. if(data&&data.code===0){
  191. Message({
  192. type: 'success',
  193. message: '已同意',
  194. });
  195. }else{
  196. Message.error('审批失败');
  197. }
  198. this.getDataList();
  199. });
  200. }).catch(() => {
  201. Message({
  202. type: 'info',
  203. message: '已取消'
  204. });
  205. });
  206. },
  207. //拒绝申请
  208. refuse(id){
  209. MessageBox.confirm('是否拒绝该发布申请?', '提示', {
  210. confirmButtonText: '确定',
  211. cancelButtonText: '取消',
  212. type: 'warning'
  213. }).then(() => {
  214. this.$http({
  215. url:this.$http.adornUrl('/algs/approval/refuse'),
  216. method:'get',
  217. params:this.$http.adornParams({
  218. approvalId:id
  219. }),
  220. }).then(({data})=>{
  221. if(data&&data.code===0){
  222. Message({
  223. type: 'success',
  224. message: '已拒绝',
  225. });
  226. }else{
  227. Message.error('审批失败');
  228. }
  229. this.getDataList();
  230. });
  231. }).catch(() => {
  232. Message({
  233. type: 'info',
  234. message: '已取消'
  235. });
  236. });
  237. },
  238. //去重
  239. unique(arr) {
  240. var ss = [];
  241. for (var i = 0; i < arr.length; i++) {
  242. ss[i] = arr[i].categoryName;
  243. }
  244. return Array.from(new Set(ss));
  245. },
  246. // 每页数
  247. sizeChangeHandle(val) {
  248. this.pageSize = val;
  249. this.pageIndex = 1;
  250. this.getDataList();
  251. },
  252. // 当前页
  253. currentChangeHandle(val) {
  254. this.pageIndex = val;
  255. this.getDataList();
  256. },
  257. // 多选
  258. selectionChangeHandle(val) {
  259. this.dataListSelections = val;
  260. },
  261. // 查看
  262. userwatch(id) {
  263. this.newWatchVisible = true;
  264. this.$nextTick(() => {
  265. this.$refs.newWatch.init(id);
  266. });
  267. },
  268. // 新增 / 修改
  269. addOrUpdateHandle(id) {
  270. this.addOrUpdateVisible = true;
  271. this.$nextTick(() => {
  272. this.$refs.addOrUpdate.init(id);
  273. });
  274. },
  275. // 删除
  276. deleteHandle(id) {
  277. var modelId = id
  278. ? [id]
  279. : this.dataListSelections.map((item) => {
  280. return item.modelId;
  281. });
  282. MessageBox.confirm(
  283. `确定对[id=${modelId.join(",")}]进行[${id ? "删除" : "批量删除"}]操作?`,
  284. "提示",
  285. {
  286. confirmButtonText: "确定",
  287. cancelButtonText: "取消",
  288. type: "warning",
  289. }
  290. )
  291. .then(() => {
  292. this.$http({
  293. url: this.$http.adornUrl("/algs/models/delete"),
  294. method: "post",
  295. data: this.$http.adornData(modelId, false),
  296. }).then(({ data }) => {
  297. if (data && data.code === 0) {
  298. Message({
  299. message: "操作成功",
  300. type: "success",
  301. duration: 1500,
  302. onClose: () => {
  303. this.getDataList();
  304. },
  305. });
  306. this.pageIndex = 1;
  307. getDataList();
  308. } else {
  309. Message.error(data.msg);
  310. }
  311. });
  312. })
  313. .catch(() => {});
  314. },
  315. },
  316. };
  317. </script>
  318. </script>
  319. <style scoped>
  320. .divi {
  321. display: block;
  322. height: 1px;
  323. width: 100%;
  324. margin: 24px 0;
  325. background-color: #dcdfe6;
  326. position: relative;
  327. }
  328. .divi2 {
  329. display: block;
  330. height: 1px;
  331. width: 100%;
  332. position: relative;
  333. }
  334. .sele {
  335. border: 1px solid #409eff;
  336. border-radius: 5px;
  337. box-sizing: border-box;
  338. padding: 5px 0px;
  339. margin: 10px;
  340. }
  341. .warningButton{
  342. color: #F56C6C;
  343. }
  344. </style>