audit-class-index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div :class="[$style.wrapHeight, $style.dataclass]">
  3. <div :class="$style.rowHeight">
  4. <div :class="$style.rightcard">
  5. <a-card>
  6. <!-- 高级搜索组件 -->
  7. <audit-advanced-query
  8. :expand="expand"
  9. :search-data="formData"
  10. :ref-name="searchform"
  11. :search-style="{ height: '150px', left: '20px', top: '57px' }"
  12. :search-fun="handleSearch"
  13. @searchedClick="searchedClick"
  14. >
  15. <template>
  16. <a-col :span="12">
  17. <a-form-model-item :label="'业务名称'" prop="indexName">
  18. <a-input v-model="formData.indexName" allow-clear />
  19. </a-form-model-item>
  20. </a-col>
  21. </template>
  22. </audit-advanced-query>
  23. <SdDataTableEx
  24. :key="key"
  25. ref="dataTable"
  26. :projectlist="true"
  27. :editnode="editnode"
  28. form-id="iamSearchCategoryidIndexname"
  29. page-id="audit\maintain\iamSearchCategoryidIndexname"
  30. :columns="columns"
  31. :actions="actions"
  32. :filter-expressions="expressions"
  33. :search-fields="['indexName']"
  34. :show-advance-query="true"
  35. :show-selection="(item) => item.editAndDeleteAuth !== 0"
  36. @searchbtnClick="searchbtnClick"
  37. >
  38. <template slot="categoryName" slot-scope="text, record">
  39. <a
  40. v-if="record.editAndDeleteAuth !== 0"
  41. @click="
  42. () => {
  43. $refs.dataTable.showDetailModal(record.id, pageId)
  44. }
  45. "
  46. >{{ text }}</a
  47. >
  48. <span v-else>{{ text }}</span>
  49. </template>
  50. <!-- 详情表单 -->
  51. <template
  52. v-slot:form="{ model }"
  53. v-sd-watermark="waterMark"
  54. :modalProps="{ height: 800 }"
  55. @saved="onSaved"
  56. >
  57. <!-- 业务名称 -->
  58. <SdFormItem label="业务名称" name="indexName">
  59. <a-select
  60. v-model="model.indexName"
  61. show-search
  62. :default-active-first-option="false"
  63. :filter-option="false"
  64. :not-found-content="null"
  65. @search="getIndexNameList"
  66. @change="searchedClick"
  67. >
  68. <a-select-option
  69. v-for="(item, i) in indexNameList"
  70. :key="item.id"
  71. class="selectoption"
  72. :value="item.indexName"
  73. >{{ item.indexName }}</a-select-option
  74. >
  75. </a-select>
  76. </SdFormItem>
  77. <a-form-model-item label="业务编号">
  78. <a-input v-model="model.id" :disabled="true" />
  79. </a-form-model-item>
  80. <SdFormItem
  81. label="业务编码"
  82. name="id"
  83. :hidden="true"
  84. :input-props="{ disabled: true }"
  85. />
  86. <SdFormItem label="索引名称" name="indexRemark" :input-props="{ disabled: true }" />
  87. <SdFormItem label="系统名称" name="systemName" :input-props="{ disabled: true }" />
  88. <SdFormItem name="indexSource" :input-props="{ disabled: true }" />
  89. <SdFormItem name="type" :input-props="{ disabled: true }">
  90. <!-- 下拉框 -->
  91. <a-select :value="model.type" :disabled="true">
  92. <a-select-option :value="0">非结构化</a-select-option>
  93. <a-select-option :value="1">结构化</a-select-option>
  94. </a-select>
  95. </SdFormItem>
  96. <!-- 分类id -->
  97. <SdFormItem name="categoryId" :hidden="true" :input-props="{ disabled: true }" />
  98. <!--分类名称 -->
  99. <!-- systemId -->
  100. <SdFormItem name="systemId" :hidden="true" :input-props="{ disabled: true }" />
  101. <!-- id -->
  102. </template>
  103. <!-- 索引类型 0 非结构化 1 结构化 -->
  104. <template slot="type" slot-scope="text, record">
  105. <span v-if="record.type === 0 || record.type === '0'">非结构化</span>
  106. <span v-else>结构化</span>
  107. </template>
  108. </SdDataTableEx>
  109. </a-card>
  110. </div>
  111. </div>
  112. </div>
  113. </template>
  114. <script>
  115. import { Modal, message } from 'ant-design-vue'
  116. import axios from '@/common/services/axios-instance'
  117. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  118. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  119. import auditAdvancedGroupMixins from '../../components/audit-advanced-group-mixins'
  120. import crossWindowWatcher from '@/common/services/cross-window-watcher'
  121. import SdDataTableEx from '@/common/components/sd-data-table-ex.vue'
  122. import SdFormItem from '@/common/components/sd-form-item.vue'
  123. import dataService from './data-config'
  124. import TableActionTypes from '@/common/services/table-action-types'
  125. export default {
  126. name: 'AuditClassIndex',
  127. metaInfo: {
  128. title: '审搜索引',
  129. },
  130. components: {
  131. SdDataTableEx,
  132. SdFormItem,
  133. auditAdvancedQuery,
  134. },
  135. mixins: [auditAdvancedQueryMixins, auditAdvancedGroupMixins],
  136. data() {
  137. return {
  138. editnode: true,
  139. key: 0,
  140. searchform: 'searchform',
  141. formData: {
  142. indexName: '',
  143. categoryId: '',
  144. },
  145. pageId: 'audit' + '/' + 'maintain' + '/' + 'iamSearchCategoryidIndexname',
  146. auditOrgId: null,
  147. parentId: 0,
  148. parentCategoryId: '000000',
  149. level: 1,
  150. isEnd: null,
  151. indexNameList: [],
  152. columns: [
  153. {
  154. title: '序号',
  155. dataIndex: 'sortNum',
  156. customRender: (text, record, index) => `${index + 1}`,
  157. },
  158. {
  159. title: '业务编号',
  160. dataIndex: 'id',
  161. },
  162. {
  163. title: '索引名',
  164. dataIndex: 'indexName',
  165. },
  166. {
  167. title: '索引说明',
  168. dataIndex: 'indexRemark',
  169. },
  170. {
  171. title: '系统名称',
  172. dataIndex: 'systemName',
  173. },
  174. {
  175. title: '系统来源名称',
  176. dataIndex: 'indexSource',
  177. },
  178. {
  179. title: '索引类型',
  180. dataIndex: 'type',
  181. scopedSlots: { customRender: 'type' },
  182. },
  183. {
  184. title: '归属分类名称',
  185. dataIndex: 'categoryName',
  186. },
  187. // 分类id
  188. {
  189. title: '分类编码',
  190. dataIndex: 'categoryId',
  191. sdHidden: true,
  192. },
  193. ],
  194. actions: [
  195. {
  196. label: '添加审搜索引',
  197. permission: 'create',
  198. id: 'new',
  199. type: TableActionTypes.primary,
  200. callback: this.create,
  201. },
  202. {
  203. label: '解绑',
  204. id: 'delete',
  205. permission: 'delete',
  206. // type: TableActionTypes.ex.delete, // 删除按钮,不需要回调,会自动处理(对sd-data-table无效)
  207. callback: () => {
  208. const ids = this.$refs.dataTable.getSelectedRowKeys()
  209. const idJson = ids.join(',')
  210. if (ids.length === 0) {
  211. return message.warning('请选择要解绑的数据')
  212. }
  213. Modal.confirm({
  214. title: '提示',
  215. content: '确认解除绑定?',
  216. onOk: () => {
  217. dataService.unbindIndex(idJson).then((res) => {
  218. if (res.data.length === 0) {
  219. message.success('解绑成功')
  220. this.$refs.dataTable.refresh()
  221. } else {
  222. Modal.confirm({
  223. title: '提示',
  224. content:
  225. res.data.join(',') +
  226. '已有授权操作无法进行解绑,请重新选择要解绑的索引后重试。',
  227. okText: '确定',
  228. cancelText: '',
  229. })
  230. }
  231. })
  232. },
  233. })
  234. },
  235. },
  236. ],
  237. expressions: [],
  238. isroot: true,
  239. className: '',
  240. onSaveForm: {
  241. id: '',
  242. indexName: '',
  243. indexRemark: '',
  244. systemName: '',
  245. indexSource: '',
  246. type: '',
  247. categoryName: '',
  248. categoryId: '',
  249. },
  250. onIndex: '',
  251. }
  252. },
  253. created() {
  254. this.formData.categoryId = this.$route.query.classId
  255. //
  256. this.handleSearch()
  257. this.getIndexNameList()
  258. },
  259. methods: {
  260. // 选中
  261. searchedClick(val) {
  262. // 根据val获取对应列表里的数据
  263. const indexAttr = this.indexNameList.find((item) => item.indexName === val)
  264. // 如果已经categoryid 不为空或者null则提示该索引已绑定其他分类
  265. if (indexAttr.categoryId === null || indexAttr.categoryId === '') {
  266. //
  267. this.$refs.dataTable.getDetailModal().SdForm.model = {
  268. ...this.$refs.dataTable.getDetailModal().SdForm.model,
  269. }
  270. // 如果model内有indexAttr同名字段则重新赋值
  271. for (const key in indexAttr) {
  272. if (Object.keys(this.$refs.dataTable.getDetailModal().SdForm.model).includes(key)) {
  273. this.$refs.dataTable.getDetailModal().SdForm.model[key] = indexAttr[key]
  274. }
  275. }
  276. // categoryid 为分类id categoryNmae 为分类名称
  277. this.$refs.dataTable.getDetailModal().SdForm.model.categoryId = this.$route.query.classId
  278. this.$refs.dataTable.getDetailModal().SdForm.model.categoryName = this.$route.query.className
  279. } else {
  280. // 清空indexName
  281. this.$refs.dataTable.getDetailModal().SdForm.model.indexName = ''
  282. return message.warning('该索引已绑定其他分类')
  283. }
  284. // 如果
  285. // 获取表单详情
  286. },
  287. getIndexNameList(value = '') {
  288. const params = {
  289. columns:
  290. 'sortNum,id,indexName,indexRemark,systemName,indexSource,type,categoryName,categoryId,systemId',
  291. maxResults: 9999,
  292. startPosition: 0,
  293. expressions: [
  294. {
  295. dataType: 'str',
  296. name: 'indexName',
  297. op: 'like',
  298. stringValue: '%' + value + '%',
  299. },
  300. ],
  301. buttonExpressions: [],
  302. formId: 'iamSearchCategoryidIndexname',
  303. }
  304. dataService.findIndexList(params).then((res) => {
  305. this.indexNameList = res.data.data
  306. // 过滤掉已经绑定的索引
  307. this.indexNameList = this.indexNameList.filter((item) => {
  308. return item.categoryId === null || item.categoryId === ''
  309. })
  310. })
  311. },
  312. handleSearch() {
  313. this.expressions = []
  314. // 业务名称
  315. this.formData.indexName &&
  316. this.expressions.push({
  317. dataType: 'str',
  318. name: 'indexName',
  319. op: 'like',
  320. stringValue: '%' + this.formData.indexName + '%',
  321. })
  322. // 分类id
  323. this.formData.categoryId &&
  324. this.expressions.push({
  325. dataType: 'str',
  326. name: 'categoryId',
  327. op: 'like',
  328. stringValue: `%${this.formData.categoryId}%`,
  329. })
  330. },
  331. // 新增
  332. create() {
  333. this.key++
  334. this.getIndexNameList()
  335. this.$nextTick(() => {
  336. this.$refs.dataTable.showDetailModal(null, 'audit/maintain/iamSearchCategoryidIndexname')
  337. })
  338. },
  339. refresh() {
  340. this.$refs.dataTable.refresh()
  341. },
  342. },
  343. }
  344. </script>
  345. <style module lang="scss">
  346. @use '@/common/design' as *;
  347. .wrap-height {
  348. height: 100%;
  349. .row-height {
  350. display: flex;
  351. flex: auto;
  352. height: 100%;
  353. .rightcard {
  354. flex: 1;
  355. width: calc(100% - 20%);
  356. height: 100%;
  357. }
  358. }
  359. }
  360. .dataclass {
  361. :global(.projectlist .ant-table-empty .ant-table-body) {
  362. overflow-x: hidden !important;
  363. }
  364. :global(span > .ant-btn:nth-child(2)) {
  365. color: #fff;
  366. background-color: #1890ff;
  367. border-color: #1890ff;
  368. }
  369. // :global(.ant-table-placeholder) {
  370. // width: auto;
  371. // }
  372. }
  373. </style>