index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="p-4">
  3. <div class="top-search">
  4. <div class="left-search-input">
  5. <div class="input">
  6. <span>关键字</span>
  7. <a-input allowClear v-model:value="searchValue" style="width: 200px;" placeholder="请输入资源名称"></a-input>
  8. </div>
  9. <div class="input">
  10. <span>资源类型</span>
  11. <!-- <a-select allowClear v-model:value="selectTypeValue" style="width: 200px" :options="typeOptions"></a-select> -->
  12. <a-select @change="handleTypeChange" v-model:value="selectTypeValue" style="width: 200px"
  13. :options="typeOptions"></a-select>
  14. </div>
  15. <div class="input" v-if="selectTypeValue != 'SR'">
  16. <span>应用系统</span>
  17. <a-select v-model:value="selectSystemValue" style="width: 200px" :options="sysOptions"></a-select>
  18. </div>
  19. <div class="input">
  20. <span>审核状态</span>
  21. <a-select @change="changeStatus" v-model:value="selectStatusValue" style="width: 200px"
  22. :options="statusOptions">
  23. </a-select>
  24. </div>
  25. <!-- <div class="input">
  26. <span>申请时间</span>
  27. <a-date-picker v-model:value="searchTime" placeholder="申请时间" style="width: 200px" />
  28. </div> -->
  29. </div>
  30. <div class="right-btns">
  31. <a-button style="margin-right: 15px;" @click="handleReset">重置</a-button>
  32. <a-button type="primary" @click="handleSearch">查询</a-button>
  33. </div>
  34. </div>
  35. <div class="bottom-table">
  36. <BasicTable @register="registerTable" class="basic-table" @fetch-success="onFetchSuccess">
  37. <template #toolbar>
  38. <a-button style="background-color: #fc8b01;color: #fff;" :disabled="hasSelected"
  39. @click="handleAuditAll">批量审核</a-button>
  40. </template>
  41. <template #BLZT="{ record }">
  42. <a-tag :style="`color:${record.status === 3 || record.status === 3 ? 'red' : ''};`">
  43. {{
  44. record.BLZT == '在办' ? '审核中' : record.BLZT == '已办结' ? '审核完' : ''
  45. }}
  46. </a-tag>
  47. </template>
  48. <template #ISPASS="{ record }">
  49. {{
  50. record.ISPASS == '1' ? '同意' : record.ISPASS == '0' ? '不同意' : ''
  51. }}
  52. </template>
  53. <template #action="{ record }">
  54. <TableAction :actions="[
  55. {
  56. label: '详情',
  57. tooltip: '详情',
  58. onClick: handleDetail.bind(null, record),
  59. },
  60. {
  61. label: '审核',
  62. tooltip: '审核',
  63. disabled: selectStatusValue == '0' ? false : true,
  64. onClick: handleAudit.bind(null, record),
  65. }
  66. ]" />
  67. </template>
  68. </BasicTable>
  69. </div>
  70. <AuditModal v-if="ischect && showAuditModal" @closeModal="showAuditModal = false" :bussInfo="bussInfo"
  71. @onSubmit="onSubmit" />
  72. <map-resource-upload v-if="!ischect && selectTypeValue === 'MR'" @register="registerModal"
  73. @success="handleSuccess"></map-resource-upload>
  74. <scene-resource-upload v-if="!ischect && selectTypeValue === 'ER'" @register="registerModal"
  75. @success="handleSuccess"></scene-resource-upload>
  76. <file-resource-upload v-if="!ischect && selectTypeValue === 'DR'" @register="registerModal"
  77. @success="handleSuccess"></file-resource-upload>
  78. <ass-resource-upload v-if="!ischect && selectTypeValue === 'SR'" @register="registerModal"
  79. @success="handleSuccess"></ass-resource-upload>
  80. </div>
  81. </template>
  82. <script>
  83. import { defineComponent, reactive, ref, onMounted, watch, toRefs, computed, createVNode, nextTick } from 'vue';
  84. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  85. import AuditModal from './AuditModal.vue';
  86. import { columns } from './map.data';
  87. import { list } from '/@/api/authorize/authorize';
  88. import moment from 'moment';
  89. import { session } from '/@/utils/Memory';
  90. import { queryTaskInfoPage, queryTaskYbInfoPage } from '/@/api/resource/examine';
  91. import { getAppDesign } from '/@/api/oem';
  92. // import { useRouter } from 'vue-router'
  93. import MapResourceUpload from '/@/views/dataAdmin/dataAdmin/mapUpload/MapSourceModal.vue';
  94. import FileResourceUpload from '/@/views/dataAdmin/dataAdmin/fileResourceUpload/AddMethod.vue';
  95. import SceneResourceUpload from '/@/views/dataAdmin/dataAdmin/sceneResourceUpload/AddMethod.vue';
  96. import AssResourceUpload from '/@/views/dataAdmin/assembly/MapSourceModal.vue';
  97. import { useModal } from '/@/components/Modal';
  98. import { queryResourceById } from '/@/api/resource/map';
  99. import { useAppStore } from '/@/store/modules/app';
  100. import { useRouter } from 'vue-router';
  101. import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
  102. export default defineComponent({
  103. name: 'Empowerment',
  104. components: { BasicTable, TableAction, AuditModal, MapResourceUpload, FileResourceUpload, SceneResourceUpload, AssResourceUpload },
  105. setup() {
  106. const [registerModal, { openModal }] = useModal();
  107. const ischect = ref(true)
  108. const appStore = useAppStore();
  109. const searchValue = ref('')
  110. const selectSystemValue = ref('')
  111. const selectStatusValue = ref('0')
  112. const searchTime = ref(null)
  113. const { currentRoute } = useRouter();
  114. const currRoute = currentRoute.value;
  115. const selectTypeValue = ref(currRoute.query.type || 'MR')
  116. //mr是地图资源,dr是文件,er场景,sr组件
  117. const typeOptions = [
  118. {
  119. label: "地图资源",
  120. value: "MR"
  121. },
  122. {
  123. label: "场景资源",
  124. value: "ER"
  125. },
  126. {
  127. label: "文件资源",
  128. value: "DR"
  129. },
  130. {
  131. label: "组件资源",
  132. value: "SR"
  133. },
  134. {
  135. label: "接口服务",
  136. value: "interface"
  137. }
  138. ]
  139. function handleTypeChange() {
  140. }
  141. const sysOptions = ref([]);
  142. onMounted(() => getApp());
  143. function getApp() {
  144. list().then(r => sysOptions.value = r.map(i => { return { label: i.NAME, value: i.KEY } }))
  145. }
  146. const statusOptions = [
  147. {
  148. // label: "在办",
  149. label: "待办",
  150. value: "0"
  151. },
  152. {
  153. label: "已办结",
  154. value: "1"
  155. }
  156. ]
  157. function changeStatus() {
  158. }
  159. const showAuditModal = ref(false)
  160. const bussInfo = ref({
  161. bussInfoId: "",
  162. resId: ""
  163. })
  164. onMounted(() => {
  165. // getAllData();
  166. })
  167. //获取所有状态的资源
  168. const getAllData = () => {
  169. return new Promise(async (resolve) => {
  170. let params = {
  171. page: 1,
  172. rows: 10000,
  173. serviceType: selectTypeValue.value,
  174. userId: session.getItem('userId'),
  175. keyStr: searchValue.value
  176. }
  177. let resdb = null;
  178. let resyb = null;
  179. if (selectStatusValue.value == "0") {
  180. resdb = await queryTaskInfoPage(params)
  181. resyb = [];
  182. } else if (selectStatusValue.value == "1") {
  183. resdb = []
  184. resyb = await queryTaskYbInfoPage(params)
  185. } else {
  186. resdb = await queryTaskInfoPage(params)
  187. resyb = await queryTaskYbInfoPage(params)
  188. }
  189. let allData = removeDp(resyb, resdb)
  190. if (allData.length) {
  191. allData.filter(item => item.BUSSNAME.indexOf('授权') > -1)
  192. allData.map(i => i.id = i.BUSSID);
  193. console.log("授权审核列表:", allData)
  194. resolve(allData)
  195. } else {
  196. resolve([])
  197. }
  198. })
  199. }
  200. //两个对象数组去重
  201. const removeDp = (arr1, arr2) => {
  202. let arr = arr1.concat(arr2)
  203. let obj = {}
  204. let newArray = arr.reduce((pre, cur) => {
  205. if (!obj[cur.BUSSID]) {
  206. obj[cur.BUSSID] = true
  207. pre.push(cur)
  208. }
  209. return pre
  210. }, [])
  211. return newArray;
  212. }
  213. //注册表格
  214. const [registerTable, { reload, setProps, getRowSelection, getSelectRowKeys, clearSelectedRowKeys, getSelectRows, getDataSource }] = useTable({
  215. title: '授权资源列表',
  216. api: getAllData,
  217. // dataSource: [],
  218. columns,
  219. rowSelection: { type: 'checkbox' },
  220. useSearchForm: false,
  221. showTableSetting: true,
  222. bordered: false,
  223. striped: false,
  224. canResize: true,
  225. showIndexColumn: true,
  226. indexColumnProps: { fixed: 'left' },
  227. actionColumn: {
  228. width: 120,
  229. title: '操作',
  230. dataIndex: 'action',
  231. slots: { customRender: 'action' },
  232. fixed: 'right',
  233. },
  234. pagination: {
  235. hideOnSinglePage: false,
  236. },
  237. // rowKey: (record) => record.BUSSID,
  238. // rowKey: 'BUSSID',
  239. clickToRowSelect: false,
  240. tableSetting: {
  241. redo: true,
  242. size: true,
  243. setting: false,
  244. fullScreen: false
  245. },
  246. });
  247. const { selectionOptions } = useBatchDelete();
  248. selectionOptions.rowSelection.getCheckboxProps = () => {
  249. return { disabled: selectStatusValue.value == '1' ? true : false };
  250. };
  251. nextTick(() => {
  252. setProps(selectionOptions);
  253. });
  254. //判断是否选中数据
  255. const hasSelected = computed(() => {
  256. const rowSelection = getRowSelection();
  257. return !(rowSelection.selectedRowKeys?.length);
  258. });
  259. //重置查询
  260. const handleReset = () => {
  261. searchValue.value = ''
  262. selectTypeValue.value = ''
  263. selectSystemValue.value = ''
  264. selectStatusValue.value = '0'
  265. searchTime.value = moment()
  266. }
  267. //条件查询
  268. const handleSearch = () => {
  269. reload();
  270. }
  271. //资源详情
  272. const handleDetail = async (record) => {
  273. ischect.value = false;
  274. const res = await queryResourceById(record?.SERVICEID);
  275. if (res) {
  276. if (res.dataVersionConf) {
  277. res.metadata.isnew = res.servicebase.isnew = res.dataVersionConf.active == 'Y' ? "1" : "0";
  278. }
  279. const result = Object.assign(res.metadata, res.servicebase, res.dataVersionConf || {});
  280. if (record.bussid) res.bussid = record.BUSSID;
  281. openModal(true, {
  282. record: result,
  283. isUpdate: true,
  284. isView: true,
  285. });
  286. }
  287. }
  288. // 批量审核
  289. const handleAuditAll = () => {
  290. var arr = getSelectRowKeys();
  291. ischect.value = true;
  292. console.log("多个审核打开审核弹窗:", arr)
  293. bussInfo.value.bussInfoId = arr.toString();
  294. bussInfo.value.resId = false;
  295. bussInfo.value.record = false;
  296. showAuditModal.value = true;
  297. appStore.setRouterPushAuditFlag(false)
  298. }
  299. //单个审核,打开审核弹窗
  300. const handleAudit = (record) => {
  301. ischect.value = true;
  302. console.log("单个审核打开审核弹窗:", record)
  303. bussInfo.value.bussInfoId = record.BUSSID;
  304. bussInfo.value.resId = record.SERVICEID;
  305. bussInfo.value.record = record;
  306. showAuditModal.value = true;
  307. appStore.setRouterPushAuditFlag(false)
  308. }
  309. //审核提交
  310. const onSubmit = (isPass) => {
  311. showAuditModal.value = false
  312. reload()
  313. }
  314. const onFetchSuccess = () => {
  315. // 请求后拿到数据,打开对应的资源审核弹窗
  316. nextTick(() => {
  317. let dataList = getDataSource()
  318. if (currRoute?.query?.bussid && appStore.routerPushAuditFlag) {
  319. dataList.forEach(item => {
  320. item.BUSSID === currRoute.query.bussid && handleAudit(item)
  321. })
  322. }
  323. });
  324. }
  325. return {
  326. changeStatus,
  327. ischect,
  328. handleTypeChange,
  329. showAuditModal,
  330. bussInfo,
  331. searchValue,
  332. selectTypeValue,
  333. selectSystemValue,
  334. selectStatusValue,
  335. searchTime,
  336. typeOptions,
  337. sysOptions,
  338. statusOptions,
  339. hasSelected,
  340. registerTable,
  341. registerModal,
  342. handleReset,
  343. handleSearch,
  344. handleAuditAll,
  345. handleDetail,
  346. handleAudit,
  347. onSubmit,
  348. onFetchSuccess
  349. };
  350. },
  351. });
  352. </script>
  353. <style lang="less" scoped>
  354. .p-4 {
  355. height: 100%;
  356. .top-search {
  357. width: 100%;
  358. height: 74px;
  359. border-radius: 6px;
  360. background: #FFFFFF;
  361. display: flex;
  362. justify-content: space-between;
  363. align-items: center;
  364. .left-search-input {
  365. margin-left: 20px;
  366. display: flex;
  367. .input {
  368. margin-right: 30px;
  369. span {
  370. margin-right: 10px;
  371. }
  372. }
  373. }
  374. .right-btns {
  375. margin-right: 20px;
  376. }
  377. }
  378. .bottom-table {
  379. margin-top: 24px;
  380. padding: 20px;
  381. height: calc(100% - 98px);
  382. background-color: #fff;
  383. .basic-table {
  384. height: 100%;
  385. ::v-deep .ant-table-title {
  386. padding: 0 !important;
  387. .vben-basic-title {
  388. font-family: '阿里巴巴普惠体 2.0';
  389. font-size: 16px;
  390. font-weight: bold;
  391. color: #333333;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. </style>