audit-model-form.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <audit-form-top-banner>
  3. <template slot="afterbtn">
  4. <div :class="$style.btns">
  5. <a-button type="primary" :disabled="!showPublish" @click="openPage('fb')">发布</a-button>
  6. <a-button type="primary" :disabled="!showShare" @click="openPage('gx')">共享</a-button>
  7. <!-- 开启调度 -->
  8. <!-- <a-button type="primary" @click="checkPublish('dd')">开始调度</a-button> -->
  9. <a-button type="primary" @click="saveForm">保存</a-button>
  10. </div>
  11. </template>
  12. <SdDetailForm
  13. ref="docform"
  14. :key="onKey"
  15. form-id="iamModelMaintain"
  16. page-id="audit/maintain/iamModelMaintain"
  17. :record-id="this.$route.query.record ? parseInt(this.$route.query.record) : null"
  18. :read-only="this.$route.query.type === 'readonly'"
  19. :class="$style.form"
  20. @close="close(true)"
  21. @saved="saved"
  22. >
  23. <template v-slot="{ model, fields }">
  24. <table>
  25. <tr>
  26. <td style="padding-left:5px;border:none">
  27. <audit-advanced-group
  28. :expand="templateExpand"
  29. :expand-str="'templateExpand'"
  30. :group-label="'基本信息'"
  31. tablestyle="''"
  32. @changedClick="changedClick"
  33. ></audit-advanced-group> </td></tr
  34. ></table>
  35. <table v-show="templateExpand">
  36. <tr style="display:none">
  37. <!-- 模型编号 -->
  38. <SdFormItemTd name="auditOrgId" />
  39. </tr>
  40. <tr>
  41. <!-- 模型编号 -->
  42. <!-- <SdFormItemTd name="id" label="模型编号" :input-props="{ disabled: true }" /> -->
  43. <SdFormItemTd name="modelCode" label="模型编号" :input-props="{ disabled: true }" />
  44. <!-- 模型名称 -->
  45. <SdFormItemTd name="modelName">
  46. <a-form-model-item
  47. :rules="[
  48. {
  49. validator: validatorModelName,
  50. trigger: ['blur'],
  51. },
  52. ]"
  53. prop="modelName"
  54. >
  55. <a-input v-model="model.modelName" />
  56. </a-form-model-item>
  57. </SdFormItemTd>
  58. </tr>
  59. <tr>
  60. <!-- 模型类型 new -->
  61. <SdFormItemTd
  62. v-if="modelTypeFocus(fields.modelType.attr.selectListItem, 'init')"
  63. name="modelType"
  64. >
  65. <a-select
  66. v-model="model.modelType"
  67. @change="modelTypeChange"
  68. @focus="modelTypeFocus(fields.modelType.attr.selectListItem)"
  69. >
  70. <a-select-option
  71. v-for="(item, i) in fields.modelType.attr.selectListItem"
  72. :key="i"
  73. :value="item.value"
  74. >{{ item.label }}</a-select-option
  75. >
  76. </a-select>
  77. </SdFormItemTd>
  78. <!-- 事件标签 -->
  79. <SdFormItemTd name="eventTag" :colspan="1" label="事件标签分类">
  80. <a-select v-model="model.eventTag" @change="eventChange">
  81. <a-select-option v-for="(item, i) in eventList" :key="i" :value="item.id">{{
  82. item.tagName + '-' + item.id
  83. }}</a-select-option>
  84. </a-select>
  85. </SdFormItemTd>
  86. </tr>
  87. <tr>
  88. <!-- 整改截至时间 , 状态-->
  89. <SdFormItemTd name="reformTime" label="整改截至时间">
  90. <div class="reform-time-maintain-from">
  91. <a-input-number
  92. v-model="model.reformTime"
  93. :min="minSize"
  94. :disabled="model.modelType !== '1'"
  95. class="reform-time-data"
  96. ></a-input-number>
  97. <sd-form-item name="reformTimeType" label=""></sd-form-item>
  98. </div>
  99. </SdFormItemTd>
  100. <SdFormItemTd name="viewAddress">
  101. <a-button type="primary" :disabled="!model.jmId" @click="onViewJm(model.jmId)"
  102. >查看</a-button
  103. >
  104. </SdFormItemTd>
  105. <!-- <SdFormItemTd name="jmTable" label="模型下发数据表"> </SdFormItemTd> -->
  106. </tr>
  107. <tr>
  108. <!-- 模型领域, 模型阶段 -->
  109. <SdFormItemTd name="modelDomain">
  110. <a-select v-model="model.modelDomain" :disabled="true" @change="areaChange">
  111. <a-select-option v-for="(item, i) in areaOption" :key="i" :value="item.id">{{
  112. item.name
  113. }}</a-select-option>
  114. </a-select>
  115. </SdFormItemTd>
  116. <SdFormItemTd name="modelPhase">
  117. <a-select v-model="model.modelPhase" @change="stageChange">
  118. <a-select-option v-for="(item, i) in stageOption" :key="i" :value="item.id">{{
  119. item.name
  120. }}</a-select-option>
  121. </a-select>
  122. </SdFormItemTd>
  123. </tr>
  124. <!-- 查看数据地址, 编辑数据地址 -->
  125. <tr>
  126. <!-- 是否追责 -->
  127. <!-- <SdFormItemTd name="isAccountable" /> -->
  128. <!-- <SdFormItemTd name="editAddress" /> -->
  129. </tr>
  130. <tr>
  131. <SdFormItemTd name="catalogId" label="所属分类">
  132. <a-select v-model="model.catalogId" :disabled="true" @change="cataLogChange">
  133. <a-select-option v-for="(item, i) in catalogOption" :key="i" :value="item.id">{{
  134. item.categoryName
  135. }}</a-select-option>
  136. </a-select>
  137. </SdFormItemTd>
  138. <SdFormItemTd name="datacubeType" label="建模类型">
  139. <a-select v-model="model.datacubeType" :disabled="true" @change="cataLogChange">
  140. <a-select-option v-for="(item, i) in modelTypeList" :key="i" :value="item.id">{{
  141. item.name
  142. }}</a-select-option>
  143. </a-select>
  144. </SdFormItemTd>
  145. </tr>
  146. <tr>
  147. <!-- 整改说明 -->
  148. <SdFormItemTd name="reformDesc" :colspan="3">
  149. <a-textarea v-model="model.reformDesc" :rows="3" />
  150. </SdFormItemTd>
  151. </tr>
  152. <tr>
  153. <SdFormItemTd name="risk" label="关注风险" :colspan="3">
  154. <a-textarea v-model="model.risk" :rows="3" />
  155. </SdFormItemTd>
  156. </tr>
  157. <SdFormItemTd :hidden="true" name="catalogName" />
  158. </table>
  159. <template v-if="$route.query.record">
  160. <table style="margin-top: 20px"
  161. ><tr
  162. ><td style="padding-left:5px;border:none;">
  163. <audit-advanced-group
  164. :expand="regularExpand"
  165. :expand-str="'regularExpand'"
  166. :group-label="'定时任务'"
  167. @changedClick="changedClick"
  168. >
  169. <audit-regular-time
  170. v-show="regularExpand"
  171. :model="model"
  172. :readonly="$route.query.type === 'readonly'"
  173. ></audit-regular-time>
  174. </audit-advanced-group> </td></tr
  175. ></table>
  176. </template>
  177. <table>
  178. <tr>
  179. <td style="padding-left:5px;border:none">
  180. <audit-advanced-group
  181. :expand="devExpand"
  182. :expand-str="'devExpand'"
  183. :group-label="'模型逻辑'"
  184. @changedClick="changedClick"
  185. ></audit-advanced-group>
  186. </td>
  187. </tr>
  188. </table>
  189. <table v-if="devExpand">
  190. <tr>
  191. <sd-quill-editor
  192. v-model="model.configIdea"
  193. :options="editorOption"
  194. @onreset="() => onKey++"
  195. />
  196. </tr>
  197. </table>
  198. <!-- // 代码逻辑,开发思路,配置思路 -->
  199. <!-- 每个模块下只有一个 a-textarea -->
  200. <table>
  201. <tr>
  202. <td style="padding-left:5px;border:none">
  203. <audit-advanced-group
  204. :expand="codeExpand"
  205. :expand-str="'codeExpand'"
  206. :group-label="'代码逻辑'"
  207. @changedClick="changedClick"
  208. ></audit-advanced-group>
  209. </td>
  210. </tr>
  211. </table>
  212. <table v-if="codeExpand">
  213. <sd-quill-editor v-model="model.codeLogic" :options="editorOption" />
  214. </table>
  215. </template>
  216. </SdDetailForm>
  217. </audit-form-top-banner>
  218. </template>
  219. <script>
  220. import { Message } from 'ant-design-vue'
  221. import auditFormTopBanner from '@product/iam/components/audit-form-top-banner.vue'
  222. import components from './_import-components/audit-model-form-import'
  223. import SdDetailForm from '@/common/components/sd-detail-form.vue'
  224. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  225. import auditMaintainService from '../maintain/audit-maintain-service'
  226. import auditAdvancedGroup from '../../components/audit-advanced-group.vue'
  227. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  228. import SdFormItemTd from '@/common/components/sd-form-item-td.vue'
  229. import auditModelService from './audit-model-service'
  230. import debounce from 'lodash.debounce'
  231. import axios from '@/common/services/axios-instance'
  232. import auditRegularTime from '../maintain/audit-regular-time.vue'
  233. export default {
  234. name: 'AuditModelForm',
  235. metaInfo: {
  236. title: '模型信息管理',
  237. },
  238. components: {
  239. ...components,
  240. SdFormItemTd,
  241. auditAdvancedGroup,
  242. auditFormTopBanner,
  243. SdDetailForm,
  244. auditRegularTime,
  245. },
  246. mixins: [auditAdvancedGroupMixins],
  247. data() {
  248. return {
  249. modelTypeList: [
  250. {
  251. id: 1,
  252. name: 'SQL建模',
  253. },
  254. {
  255. id: 0,
  256. name: '数据集建模',
  257. },
  258. ],
  259. regularExpand: true,
  260. onKey: 1,
  261. onModelType: '',
  262. onModelCode: '',
  263. templateExpand: true,
  264. // 代码逻辑,开发思路,配置思路
  265. codeExpand: true,
  266. configExpand: true,
  267. devExpand: true,
  268. orgId: '',
  269. // 是否显示发布,或者共享按钮
  270. showPublish: false,
  271. showShare: false,
  272. eventList: [],
  273. // 模型领域 ,模型阶段
  274. areaOption: [],
  275. stageOption: [],
  276. // 所属分类
  277. catalogOption: [],
  278. // 分类id
  279. // 名称
  280. optionSelect: {
  281. area: '',
  282. stage: '',
  283. event: '',
  284. },
  285. flagAll: [],
  286. allStatus: false,
  287. // 时间类型
  288. eventClassOption: [],
  289. // 是否追责
  290. isAccountable: false,
  291. // 刷新表单
  292. key: 0,
  293. // 类型option
  294. typeOption: [],
  295. // 富文本
  296. editorOption: {
  297. modules: {
  298. toolbar: {
  299. container: [
  300. ['bold', 'italic', 'underline', 'strike'], // toggled buttons
  301. ['blockquote', 'code-block'],
  302. [{ header: 1 }, { header: 2 }], // custom button values
  303. [{ list: 'ordered' }, { list: 'bullet' }],
  304. [{ script: 'sub' }, { script: 'super' }], // superscript/subscript
  305. [{ indent: '-1' }, { indent: '+1' }], // outdent/indent
  306. [{ direction: 'rtl' }], // text direction
  307. [{ size: ['small', false, 'large', 'huge'] }], // custom dropdown
  308. [{ header: [1, 2, 3, 4, 5, 6, false] }],
  309. [{ color: [] }, { background: [] }], // dropdown with defaults from theme
  310. [{ font: [] }],
  311. [{ align: [] }],
  312. ['clean'], // remove formatting button
  313. ['link', 'image'], // link and image, video
  314. ],
  315. },
  316. },
  317. },
  318. modelFiled: {},
  319. times: null,
  320. }
  321. },
  322. computed: {
  323. isAddStatus() {
  324. return this.$route.query.record === undefined
  325. },
  326. },
  327. watch: {
  328. flagAll: {
  329. handler(val) {
  330. if (val.length === 2) {
  331. setTimeout(() => {
  332. if (this.$refs.docform?.SdForm?.model !== undefined) {
  333. const {
  334. modelPhase,
  335. modelDomain,
  336. modelDomainName,
  337. modelPhaseName,
  338. } = this.$refs.docform.SdForm.model
  339. if (modelPhase) {
  340. const stage = this.stageOption.filter((item) => item.id === modelPhase)
  341. stage.length === 0 &&
  342. this.stageOption.push({
  343. id: modelPhase,
  344. name: modelPhaseName,
  345. })
  346. }
  347. if (modelDomain) {
  348. const area = this.areaOption.filter((item) => item.id === modelDomain)
  349. area.length === 0 &&
  350. this.areaOption.push({
  351. id: modelDomain,
  352. name: modelDomainName,
  353. })
  354. }
  355. }
  356. if (this.times) {
  357. clearTimeout(this.times)
  358. }
  359. }, 100)
  360. }
  361. },
  362. deep: true,
  363. },
  364. },
  365. created() {
  366. if (this.$route.query.orgId) this.orgId = this.$route.query.orgId
  367. this.getFormOption()
  368. },
  369. methods: {
  370. returnRegular(val) {
  371. this.onModelCode = val.modelCode
  372. return true
  373. },
  374. // 模型名称校验
  375. validatorModelName(rule, value, callback) {
  376. value = encodeURIComponent(value)
  377. const modelId = this.$route.query.record ? `&id=${this.$route.query.record}` : ''
  378. const url = `api/xcoa-mobile/v1/iammodelmaintain/checkModelName?modelName=${value}` + modelId
  379. debounce(() => {
  380. axios.post(url).then((res) => {
  381. if (res.data) {
  382. callback()
  383. } else {
  384. callback('已存在模型名称,不可以重复')
  385. }
  386. })
  387. }, 500)()
  388. },
  389. onViewJm(id) {
  390. if (!id) return
  391. auditModelService.getBuildUrl(id).then((res) => {
  392. if (res.data) {
  393. window.open(res.data)
  394. }
  395. })
  396. },
  397. openPage(type) {
  398. const recordId = this.$route.query.record
  399. type === 'fb' && this.checkPublish(type, recordId)
  400. type === 'gx' && window.open('#/sd-flow-guide?code=PRODUCT_IAM_MLGXSQ&record=' + recordId)
  401. },
  402. // 校验发布 如果模型下发数据表没有数据则不能发布 并提示请重新获取下发数据表后再发布
  403. checkPublish(type, recordId) {
  404. if (type === 'dd') {
  405. auditModelService.triggerModel().then(() => {
  406. Message.success({ content: '已开始调度,请稍后刷新页面后重试' })
  407. })
  408. return
  409. }
  410. const { jmTable } = this.$refs.docform.SdForm.model
  411. if (!jmTable) {
  412. Message.warning({ content: '请开启调度获取模型下发数据表数据' })
  413. return false
  414. }
  415. type === 'fb' && window.open('#/sd-flow-guide?code=PRODUCT_IAM_MLFBSQ&record=' + recordId)
  416. },
  417. getFormOption() {
  418. auditMaintainService.getEventTagList().then((res) => {
  419. this.eventList = res.data
  420. })
  421. auditMaintainService.getAreaListAll().then((res) => {
  422. this.areaOption = res.data
  423. this.flagAll.push(true)
  424. })
  425. auditMaintainService.getStageListAll().then((res) => {
  426. this.stageOption = res.data
  427. this.flagAll.push(true)
  428. })
  429. // 获取全部分类
  430. auditModelService.getAuditModelTreeAll().then((res) => {
  431. this.catalogOption = res.data
  432. })
  433. // 获取模型列表详情
  434. if (this.$route.query.record) {
  435. const data = {
  436. columns:
  437. 'sortNumber,modelName,catalogName,creationTime,shareStatus,publishStatus,reservelong2,id',
  438. maxResults: 10,
  439. startPosition: 0,
  440. expressions: [
  441. {
  442. dataType: 'str',
  443. name: 'id',
  444. op: 'eq',
  445. stringValue: this.$route.query.record,
  446. },
  447. ],
  448. buttonExpressions: [],
  449. }
  450. auditModelService.getModelListDetail(data).then((res) => {
  451. if (res.data.data.length > 0) {
  452. const { publishStatus, shareStatus } = res.data.data[0]
  453. this.showPublish = publishStatus === null
  454. this.showShare = shareStatus === null
  455. }
  456. })
  457. }
  458. },
  459. modelTypeChange(val) {
  460. this.onModelType = val
  461. this.isAccountable = val === '1'
  462. const name = this.typeOption.find((item) => item.value === val).label
  463. this.$refs.docform.setFieldValue('modelTypeName', name)
  464. // reformTime
  465. if (val !== '1') {
  466. this.$refs.docform.setFieldValue('reformTime', 0)
  467. this.minSize = 0
  468. } else {
  469. this.$refs.docform.setFieldValue('reformTime', 1)
  470. this.minSize = 1
  471. }
  472. },
  473. modelTypeFocus(filter, type) {
  474. this.typeOption = filter
  475. if (type === 'init') {
  476. this.$nextTick(() => {
  477. const val = this.$refs.docform.getFieldValue('modelType')
  478. const name = this.typeOption.find((item) => item.value === val).label
  479. this.$refs.docform.setFieldValue('modelTypeName', name)
  480. const reformTime = this.$refs.docform.getFieldValue('reformTime')
  481. if (!reformTime) {
  482. this.$refs.docform.setFieldValue('reformTime', 0)
  483. }
  484. })
  485. }
  486. return true
  487. },
  488. areaChange(val) {
  489. // 根据val的值过滤选项
  490. this.optionSelect.area = this.areaOption.find((item) => item.id === val).name
  491. },
  492. stageChange(val) {
  493. this.optionSelect.stage = this.stageOption.find((item) => item.id === val).name
  494. },
  495. // 事件标签变化
  496. eventChange(val) {
  497. this.optionSelect.event = this.eventList.find((item) => item.id === val).tagName
  498. },
  499. cataLogChange(val) {
  500. this.$refs.docform.setFieldValue('catalogId', val)
  501. this.$refs.docform.setFieldValue(
  502. 'catalogName',
  503. this.catalogOption.find((item) => item.id === val).categoryName
  504. )
  505. },
  506. close(flag) {
  507. crossWindowWatcher.notifyChange(this.$route.fullPath, flag)
  508. window.close()
  509. },
  510. // 保存
  511. saveForm() {
  512. if (this.orgId !== '') {
  513. this.$refs.docform.setFieldValue('auditOrgId', parseInt(this.orgId))
  514. }
  515. // 是否增加名字
  516. const { area, stage, event } = this.optionSelect
  517. area !== '' && this.$refs.docform.setFieldValue('modelDomainName', area)
  518. stage !== '' && this.$refs.docform.setFieldValue('modelPhaseName', stage)
  519. event !== '' && this.$refs.docform.setFieldValue('eventTagName', event)
  520. //
  521. // reservelong2 :1
  522. this.$refs.docform.setFieldValue('reservelong2', 1)
  523. this.$refs.docform.validateFields().then(() => {
  524. this.$refs.docform.saveBtnClick()
  525. })
  526. },
  527. saved() {
  528. Message.success({ content: '保存成功!' }, 1).then(() => {
  529. // this.close(true)
  530. window.close()
  531. })
  532. },
  533. initParam(model) {
  534. // 设置父id
  535. const catalogId = this.$route.query.catalogId
  536. const catalogName = this.$route.query.catalogName
  537. if (catalogId) {
  538. model.catalogId = Number(catalogId)
  539. }
  540. if (catalogName) {
  541. model.catalogName = catalogName
  542. }
  543. },
  544. createEditor() {
  545. // 创建编辑器
  546. // const editor3 = new wangEditor('#editor3')
  547. // editor3.config.height = 500
  548. // this.editor3 = editor3
  549. // editor3.create()
  550. // editor3.txt.html('<p>用 JS 设置的内容</p>')
  551. return true
  552. },
  553. setModelFiled(model) {
  554. this.modelFiled = model
  555. this.flagAll.push(true)
  556. },
  557. },
  558. }
  559. </script>
  560. <style module lang="scss">
  561. @import '@/webflow/sd-flow-form.scss';
  562. .btns button {
  563. top: 8px;
  564. float: right;
  565. margin-right: 10px;
  566. font-size: 16px;
  567. font-weight: 400;
  568. cursor: pointer;
  569. }
  570. </style>
  571. <style>
  572. .reform-time-maintain-from {
  573. display: flex;
  574. }
  575. .reform-time-data {
  576. margin-top: 4px;
  577. }
  578. </style>