audit-model-list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <template>
  2. <div :class="$style.wrapHeight">
  3. <!-- 左侧 -->
  4. <audit-model-tree ref="tree" @treeSelect="treeSelect" @depChanged="depChanged">
  5. <div :class="$style.treeWrap">
  6. <!-- 我的模型 和分类管理并列 -->
  7. <div :class="$style.treeTitle">我的模型</div>
  8. <div :class="$style.treeContent">
  9. <a-button type="primary" @click="toModel('class')">分类管理</a-button>
  10. </div>
  11. </div>
  12. </audit-model-tree>
  13. <!-- 右侧 -->
  14. <a-card :class="$style.tableRight">
  15. <!-- 列表 -->
  16. <SdDataTable
  17. ref="table"
  18. :key="key"
  19. :columns="columns"
  20. :filter-expressions="expressions"
  21. :search-fields="['modelName']"
  22. :data-url="'api/xcoa-mobile/v1/iammodelmaintain/iamModelQueryList'"
  23. :actions="actions"
  24. >
  25. <!-- 共享,发布 -->
  26. <template slot="gx" slot-scope="text, record">
  27. <span v-if="record.shareStatus === null">未共享</span>
  28. <span v-else-if="record.shareStatus === 5">已共享</span>
  29. <span v-else>审核中</span>
  30. </template>
  31. <template slot="fb" slot-scope="text, record">
  32. <span v-if="record.publishStatus === null">未发布</span>
  33. <span v-else-if="record.publishStatus === 5 || record.publishStatus === 6">已发布</span>
  34. <span v-else>待审核</span>
  35. </template>
  36. <!-- 操作 -->
  37. <template slot="edit" slot-scope="text, record">
  38. <!-- 查看,共享,发布,删除,撤销共享 -->
  39. <!-- 未发布状态 显示发布 -->
  40. <!-- 已共享状态 显示撤销共享 -->
  41. <!-- 未共享状态 显示共享 -->
  42. <!-- 以共享 或发布则不能删除 -->
  43. <a :class="$style.edit" @click="toModel('read', record)">查看</a>
  44. <!-- <a
  45. v-if="record.publishStatus === null && record.reservelong2 === 1"
  46. :class="$style.edit"
  47. @click="toModel('fb', record)"
  48. >发布</a
  49. >
  50. <span v-else-if="record.publishStatus === null" :class="$style.edit" @click="openMessage"
  51. >发布</span
  52. > -->
  53. <a
  54. v-if="record.shareStatus === null && record.reservelong2 === 1"
  55. :class="$style.edit"
  56. @click="toModel('gx', record)"
  57. >共享</a
  58. >
  59. <span v-else-if="record.shareStatus === null" :class="$style.edit" @click="openMessage"
  60. >共享</span
  61. >
  62. <a v-if="record.shareStatus === 5" :class="$style.edit" @click="cancelShare(record)"
  63. >撤销共享</a
  64. >
  65. <a
  66. v-if="
  67. record.publishStatus !== 5 && record.publishStatus !== 6 && record.shareStatus !== 5
  68. "
  69. :class="$style.edit"
  70. @click="deleteModel(record)"
  71. >删除</a
  72. >
  73. </template>
  74. </SdDataTable>
  75. </a-card>
  76. <a-modal
  77. v-model="isShowSpace"
  78. centered
  79. title="自助建模"
  80. width="800px"
  81. :confirm-loading="confirmLoading"
  82. @ok="handleOk"
  83. @cancel="close"
  84. >
  85. <a-form-model
  86. ref="spaceForm"
  87. :model="spaceForm"
  88. :rules="{
  89. modelName: [
  90. { required: true, message: '请输入模型名称', trigger: 'blur' },
  91. {
  92. validator: validatorModelName,
  93. trigger: 'blur',
  94. },
  95. ],
  96. modelType: [{ required: true, message: '请选择模型类型', trigger: 'blur' }],
  97. eventTag: [{ required: true, message: '请选择事件标签', trigger: 'blur' }],
  98. catalogName: [{ required: true, message: '请选择所属分类', trigger: 'blur' }],
  99. modelDomain: [{ required: true, message: '请选择模型领域', trigger: 'blur' }],
  100. creatModelType: [{ required: true, message: '请选择建模类型', trigger: 'blur' }],
  101. }"
  102. :label-col="{ span: 5 }"
  103. :wrapper-col="{ span: 19 }"
  104. >
  105. <!-- 模型类型 必填-->
  106. <a-form-model-item label="模型类型" prop="modelType">
  107. <a-select
  108. v-model="spaceForm.modelType"
  109. allow-clear
  110. placeholder="请选择模型类型"
  111. @change="selectChangeModelType"
  112. >
  113. <a-select-option v-for="(item, i) in modelTypeOption" :key="item.id" :value="item.id">
  114. {{ item.name }}
  115. </a-select-option>
  116. </a-select>
  117. </a-form-model-item>
  118. <!-- 所属分类 只读输入框-->
  119. <a-form-model-item label="所属分类" prop="catalogName">
  120. <a-input v-model="spaceForm.catalogName" allow-clear :disabled="true" />
  121. </a-form-model-item>
  122. <!-- 模型名称 事件标签 都是必填 -->
  123. <a-form-model-item label="模型名称" prop="modelName">
  124. <a-input v-model="spaceForm.modelName" allow-clear />
  125. </a-form-model-item>
  126. <!-- 模型code -->
  127. <a-form-model-item label="模型领域" prop="modelDomain">
  128. <!-- <a-input v-model="spaceForm.modelCode" allow-clear /> -->
  129. <!-- modelDomain -->
  130. <a-select
  131. v-model="spaceForm.modelDomain"
  132. allow-clear
  133. placeholder="请选择模型领域"
  134. @change="modelDomainChange"
  135. >
  136. <a-select-option v-for="(item, i) in modelDomainOption" :key="item.id" :value="item.id">
  137. {{ item.name }}
  138. </a-select-option>
  139. </a-select>
  140. </a-form-model-item>
  141. <!-- 事件标签 -->
  142. <a-form-model-item label="事件标签分类" prop="eventTag">
  143. <a-select
  144. v-model="spaceForm.eventTag"
  145. allow-clear
  146. placeholder="请选择事件标签"
  147. @change="selectChangeEventTag"
  148. >
  149. <a-select-option v-for="(item, i) in eventTagList" :key="item.id" :value="item.id">
  150. {{ item.tagName }}
  151. </a-select-option>
  152. </a-select>
  153. </a-form-model-item>
  154. <!-- 建模类型 -->
  155. <a-form-model-item label="建模类型" prop="creatModelType">
  156. <a-select v-model="spaceForm.creatModelType" allow-clear placeholder="请选择建模类型">
  157. <a-select-option v-for="(item, i) in modelTypeList" :key="item.id" :value="item.id">
  158. {{ item.name }}
  159. </a-select-option>
  160. </a-select>
  161. </a-form-model-item>
  162. </a-form-model>
  163. </a-modal>
  164. </div>
  165. </template>
  166. <script>
  167. import components from './_import-components/audit-model-list-import'
  168. import auditModelTree from './audit-model-tree.vue'
  169. import TableActionTypes from '@/common/services/table-action-types'
  170. import TableColumnTypes from '@/common/services/table-column-types'
  171. import { generateTree, getTreeIds } from '@product/iam/audit/dataMarket/util'
  172. import auditMaintainService from '../maintain/audit-maintain-service'
  173. import { message, Modal } from 'ant-design-vue'
  174. import auditModelService from './audit-model-service'
  175. import SdDataTable from '@/common/components/sd-data-table.vue'
  176. import { getUserInfo } from '@/common/store-mixin'
  177. import axios from '@/common/services/axios-instance'
  178. import debounce from 'lodash.debounce'
  179. export default {
  180. name: 'AuditModelList',
  181. metaInfo: {
  182. title: '模型信息管理',
  183. },
  184. components: {
  185. ...components,
  186. auditModelTree,
  187. SdDataTable,
  188. },
  189. data() {
  190. return {
  191. key: 0,
  192. // 分类管理
  193. isShowSpace: false,
  194. confirmLoading: false,
  195. spaceForm: {
  196. modelName: null, // 模型名称
  197. // modelCode: null, // 模型code
  198. modelDomain: null, // 模型领域
  199. modelDomainName: null, // 模型领域名称
  200. modelType: null, // 模型类型
  201. modelTypeName: null, // 模型类型名称
  202. catalogId: null, // 分类id
  203. catalogName: null, // 分类名称
  204. eventTag: null, // 事件标签id
  205. eventTagName: null, // 事件标签名称
  206. source: 1, // 来源 1 自助建模 2 数据集建模
  207. creatorAccount: getUserInfo().account, // 当前登录人账户
  208. creatModelType: '',
  209. },
  210. // 模型领域
  211. modelDomainOption: [],
  212. // 模型类型 分析型 0 定位型-整改类 1 定位型-关注类 2
  213. modelTypeOption: [
  214. {
  215. id: 0,
  216. name: '分析型',
  217. },
  218. {
  219. id: 1,
  220. name: '定位型-整改类',
  221. },
  222. {
  223. id: 2,
  224. name: '定位型-关注类',
  225. },
  226. ],
  227. // 建模类型
  228. modelTypeList: [
  229. {
  230. id: 1,
  231. name: 'SQL建模',
  232. },
  233. {
  234. id: 0,
  235. name: '数据集建模',
  236. },
  237. ],
  238. // 事件标签数据
  239. eventTagList: [],
  240. tableData: [],
  241. expressions: [
  242. // <!-- 创建人 -->
  243. {
  244. dataType: 'str',
  245. name: 'creatorAccount',
  246. op: 'eq',
  247. stringValue: getUserInfo().account,
  248. },
  249. //
  250. ],
  251. columns: [
  252. {
  253. title: '序号',
  254. dataIndex: 'sortNumber',
  255. customRender: (text, record, index) => `${index + 1}`,
  256. },
  257. // code name description
  258. {
  259. title: '模型名称',
  260. dataIndex: 'modelName',
  261. },
  262. {
  263. title: '所属分类',
  264. dataIndex: 'catalogName',
  265. },
  266. {
  267. title: '创建时间',
  268. dataIndex: 'creationTime',
  269. sdRender: TableColumnTypes.date,
  270. },
  271. {
  272. title: '模型共享状态',
  273. dataIndex: 'shareStatus',
  274. scopedSlots: { customRender: 'gx' },
  275. },
  276. // {
  277. // title: '发布状态',
  278. // dataIndex: 'publishStatus',
  279. // scopedSlots: { customRender: 'fb' },
  280. // },
  281. {
  282. // reservelong2
  283. dataIndex: 'reservelong2',
  284. sdHidden: true,
  285. },
  286. {
  287. title: '操作',
  288. dataIndex: 'id',
  289. width: '230px',
  290. scopedSlots: { customRender: 'edit' },
  291. },
  292. // jobName
  293. {
  294. title: '跑批任务',
  295. dataIndex: 'jobName',
  296. sdHidden: true,
  297. },
  298. ],
  299. actions: [
  300. {
  301. label: '搜索',
  302. permission: null,
  303. type: TableActionTypes.primary,
  304. callback: this.tableSearch,
  305. },
  306. // 删除
  307. // {
  308. // label: '删除',
  309. // id: 'delete',
  310. // permission: null,
  311. // type: TableActionTypes.batch,
  312. // callback: this.tableDelete,
  313. // },
  314. {
  315. label: '自助建模',
  316. permission: null,
  317. callback: this.showCreateModel,
  318. },
  319. ],
  320. // 确认保存状态
  321. rightFlag: false,
  322. }
  323. },
  324. computed: {
  325. formItemLayout() {
  326. return {
  327. layout: 'horizontal',
  328. labelCol: { span: 4 },
  329. wrapperCol: { span: 18 },
  330. }
  331. },
  332. },
  333. created() {
  334. this.initSelectData()
  335. this.getModelDomain()
  336. },
  337. methods: {
  338. modelDomainChange(value) {
  339. this.spaceForm.modelDomainName = this.modelDomainOption.find((item) => item.id === value).name
  340. },
  341. // 获取模型领域数据
  342. getModelDomain() {
  343. auditMaintainService.getAreaListAll().then((res) => {
  344. this.modelDomainOption = res.data
  345. })
  346. },
  347. openMessage() {
  348. message.warning('请进行模型信息完善')
  349. },
  350. // 模型编码校验
  351. validator(rule, value, callback) {
  352. value = encodeURIComponent(value)
  353. const url = `api/xcoa-mobile/v1/iammodelmaintain/checkCode?code=${value}`
  354. debounce(() => {
  355. axios.post(url).then((res) => {
  356. if (res.data) {
  357. callback()
  358. } else {
  359. callback('已存在模型编码,不可以重复')
  360. }
  361. })
  362. }, 500)()
  363. },
  364. // 模型名称校验
  365. validatorModelName(rule, value, callback) {
  366. value = encodeURIComponent(value)
  367. const url = `api/xcoa-mobile/v1/iammodelmaintain/checkModelName?modelName=${value}`
  368. debounce(() => {
  369. axios.post(url).then((res) => {
  370. if (res.data) {
  371. callback()
  372. } else {
  373. callback('已存在模型名称,不可以重复')
  374. }
  375. })
  376. }, 500)()
  377. },
  378. deleteModel(record) {
  379. // jobName如果是字符类型并且字符长度大于0则提示
  380. if (record.jobName !== null && record.jobName !== '') {
  381. Modal.warning({
  382. title: '提示',
  383. content: `"${record.modelName}"` + '有跑批任务在执行无法删除此模型 ',
  384. })
  385. return
  386. }
  387. // 删除
  388. // 确认是否删除
  389. Modal.confirm({
  390. title: '您确定删除这项内容吗?',
  391. content: '删除这条数据后,就无法恢复初始的状态。',
  392. cancelText: '取消',
  393. okText: '删除',
  394. okType: 'danger',
  395. onOk: () => {
  396. auditModelService.deleteModel(record.id).then((res) => {
  397. message.success('删除成功')
  398. this.$refs.table.refresh()
  399. })
  400. },
  401. onCancel: () => {},
  402. })
  403. },
  404. handleOk() {
  405. this.$refs.spaceForm.validate((valid) => {
  406. if (valid) {
  407. this.confirmLoading = true
  408. if (this.rightFlag) {
  409. return
  410. }
  411. // 两秒后可以再次点击
  412. setTimeout(() => {
  413. this.rightFlag = false
  414. }, 2000)
  415. this.rightFlag = true
  416. // 关闭弹窗
  417. const params = {
  418. ...this.spaceForm,
  419. datacubeType: this.spaceForm.creatModelType,
  420. }
  421. auditModelService.saveModelData(params).then((res) => {
  422. this.close()
  423. message.success('保存成功')
  424. window.open(res.data)
  425. this.$refs.table.refresh()
  426. this.confirmLoading = false
  427. this.rightFlag = false
  428. })
  429. }
  430. })
  431. },
  432. close() {
  433. this.confirmLoading = false
  434. this.isShowSpace = false
  435. this.isShowSpace = false
  436. const filter = ['catalogId', 'source', 'catalogName', 'creatorAccount']
  437. Object.keys(this.spaceForm).forEach((key) => {
  438. if (filter.includes(key)) {
  439. return
  440. }
  441. this.spaceForm[key] = null
  442. })
  443. },
  444. // 搜索方法
  445. handleSearch() {},
  446. showCreateModel() {
  447. // 判断是否选择了分类
  448. if (this.spaceForm.catalogId === null) {
  449. return message.error('请选择分类')
  450. }
  451. this.isShowSpace = !this.isShowSpace
  452. },
  453. //
  454. depChanged(oldId, value) {},
  455. treeSelect(selectedKeys, info) {
  456. if (selectedKeys.length === 0) {
  457. // this.parentId = null
  458. this.spaceForm.catalogId = null
  459. this.spaceForm.catalogName = null
  460. //
  461. this.expressions = this.expressions.filter((item) => item.name !== 'catalogId')
  462. return
  463. }
  464. const dataRef = info.node.dataRef
  465. if (dataRef.isroot) {
  466. this.spaceForm.catalogId = null
  467. this.spaceForm.catalogName = null
  468. this.expressions = this.expressions.filter((item) => item.name !== 'catalogId')
  469. } else {
  470. this.spaceForm.catalogId = dataRef.id
  471. this.spaceForm.catalogName = dataRef.categoryName
  472. // 删除后添加
  473. this.expressions = this.expressions.filter((item) => item.name !== 'catalogId')
  474. this.expressions.push({
  475. dataType: 'str',
  476. name: 'catalogId',
  477. op: 'eq',
  478. stringValue: dataRef.id,
  479. })
  480. }
  481. this.key += 1
  482. },
  483. // 表单select值变化
  484. selectChangeModelType(value) {
  485. this.spaceForm.modelTypeName = this.modelTypeOption.find((item) => item.id === value).name
  486. },
  487. selectChangeEventTag(value) {
  488. this.spaceForm.eventTagName = this.eventTagList.find((item) => item.id === value).tagName
  489. },
  490. initSelectData() {
  491. // 事件标签
  492. auditMaintainService.getEventTagList().then((res) => {
  493. this.eventTagList = res.data
  494. })
  495. },
  496. tableSearch() {},
  497. tableDelete() {},
  498. toModel(value, record) {
  499. // 打开新页面
  500. if (value === 'class') {
  501. window.open('#/audit-model-class')
  502. return
  503. }
  504. if (value === 'read') {
  505. window.open(`#/audit-model-form?record=${record.id}`)
  506. return
  507. }
  508. if (value === 'fb') {
  509. record.jmTable || message.warning('请获取下发数据表后再发布!')
  510. record.jmTable && window.open('#/sd-flow-guide?code=PRODUCT_IAM_MLFBSQ&record=' + record.id)
  511. return
  512. }
  513. if (value === 'gx') {
  514. window.open('#/sd-flow-guide?code=PRODUCT_IAM_MLGXSQ&record=' + record.id)
  515. return
  516. // window.open(`#/audit-model-form/${record.id}/gx`)
  517. }
  518. // 撤销共享
  519. if (value === 'cxgx') {
  520. }
  521. },
  522. // 撤销共享
  523. cancelShare(record) {
  524. // 确认是否撤销共享
  525. Modal.confirm({
  526. title: '您确定撤销共享这项内容吗?',
  527. cancelText: '取消',
  528. okText: '撤销共享',
  529. okType: 'danger',
  530. onOk: () => {
  531. auditModelService.revokeShare({ id: record.id }).then((res) => {
  532. message.success('撤销成功')
  533. this.$refs.table.refresh()
  534. })
  535. },
  536. onCancel: () => {},
  537. })
  538. },
  539. },
  540. }
  541. </script>
  542. <style module lang="scss">
  543. @use '@/common/design' as *;
  544. .wrap-height {
  545. position: relative;
  546. display: flex;
  547. height: 100%;
  548. .table-right {
  549. width: calc(100% - 20%);
  550. }
  551. }
  552. .tree-wrap {
  553. display: flex;
  554. align-items: flex-end;
  555. // 分散布局 水平居中
  556. justify-content: space-between;
  557. padding-bottom: 10px;
  558. margin-top: 10px;
  559. border-bottom: 1px solid $black;
  560. }
  561. .edit + .edit {
  562. margin-left: 10px;
  563. cursor: pointer;
  564. }
  565. </style>