ResCarModal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <!-- 申请库弹窗 -->
  3. <a-modal :visible="true" :width="width" :maskClosable="false" :destroyOnClose="true" centered :title="title"
  4. :footer="null" wrapClassName="modal-wrap" @cancel="onClose">
  5. <div class="action-content">
  6. <div class="top-search">
  7. <div class="left-search-input">
  8. <div class="input">
  9. <span>关键字</span>
  10. <a-input allowClear v-model:value="searchValue" style="width: 200px;"
  11. placeholder="请输入资源名称"></a-input>
  12. </div>
  13. <div class="input">
  14. <span>审核状态</span>
  15. <a-select allowClear v-model:value="selectValue" style="width: 200px" :options="statusOptions">
  16. </a-select>
  17. </div>
  18. <div class="input">
  19. <span>申请时间</span>
  20. <!-- <a-date-picker v-model:value="searchTime" placeholder="申请时间" style="width: 200px" /> -->
  21. <a-range-picker placeholder="申请时间" v-model:value="searchTime" />
  22. </div>
  23. </div>
  24. <div class="right-btns">
  25. <a-button style="margin-right: 15px;" @click="handleReset">重置</a-button>
  26. <a-button type="primary" @click="handleSearch">查询</a-button>
  27. </div>
  28. </div>
  29. <div class="bottom-table">
  30. <BasicTable @register="registerTable" class="basic-table">
  31. <template #toolbar>
  32. <a-button :disabled="hasSelected" style="background-color: #fc8b01;color: #fff;"
  33. @click="handleCreate">提交申请</a-button>
  34. </template>
  35. <template #action="{ record }">
  36. <TableAction :actions="[
  37. {
  38. label: '移出',
  39. tooltip: '移出',
  40. onClick: handleDelete.bind(null, record),
  41. disabled: record.shzt != '未提交' && record.shzt != '审核不通过'
  42. },
  43. {
  44. label: '提交申请',
  45. disabled: record.shzt != '未提交' && record.shzt != '审核不通过',
  46. onClick: applyHandleEdit.bind(null, record),
  47. },
  48. ]" />
  49. </template>
  50. </BasicTable>
  51. </div>
  52. </div>
  53. </a-modal>
  54. <!-- 申请弹出框 -->
  55. <ApplyModal @register="registerModal" @success="applyHandleSuccess" :type="props.type" />
  56. </template>
  57. <script>
  58. import { defineComponent, reactive, ref, onMounted, watch, toRefs, computed, createVNode } from 'vue';
  59. // 导入表格组件,表格事件
  60. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  61. import { message, Modal } from 'ant-design-vue';
  62. import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
  63. import { session } from '/@/utils/Memory';
  64. import moment from 'moment';
  65. //操作申请库资源
  66. import { getResInCar, clearResInCar, deleteResInCar } from '/@/api/resource/plat';
  67. //提交授权申请
  68. import { queryFlowInfoPage, submitExamine } from '/@/api/resource/examine';
  69. import ApplyModal from './applyModal/ApplyModal.vue';
  70. import { useModal } from '/@/components/Modal';
  71. import { columns } from "./ResCarModal.data"
  72. import { list } from '/@/api/authorize/authorize';
  73. export default defineComponent({
  74. name: 'modal',
  75. components: { BasicTable, TableAction, ApplyModal, ExclamationCircleOutlined },
  76. props: {
  77. type: {
  78. type: String,
  79. default: '',
  80. }
  81. },
  82. setup(props, { emit }) {
  83. const data = reactive({
  84. width: '1440px',
  85. title: '申请库',
  86. })
  87. const searchValue = ref('')
  88. const selectValue = ref('')
  89. const searchTime = ref([])
  90. const statusOptions = [
  91. { label: "未提交", value: "未提交" },
  92. { label: "审核中", value: "审核中" },
  93. { label: "审核通过", value: "审核通过" },
  94. { label: "审核不通过", value: "审核不通过" },
  95. ]
  96. // 请求所有申请库中的资源
  97. const getAllData = async () => {
  98. var appList = await list();
  99. return new Promise((resolve) => {
  100. getResInCar({
  101. keyword: searchValue.value,
  102. shzt: selectValue.value,
  103. sqsj: searchTime.value.length == 2 ? moment(searchTime.value[0]).format('YYYY-MM-DD') : '',
  104. endSqsj: searchTime.value.length == 2 ? moment(searchTime.value[1]).format('YYYY-MM-DD') : '',
  105. userId: session.getItem('userId'),
  106. }).then((res) => {
  107. if (res?.datas?.length) {
  108. let resData = []
  109. res.datas.forEach(item => {
  110. //筛掉接口服务
  111. var type = item.applyCarInfo.workflowType;
  112. if (type == props.type) {
  113. if (item?.resInfo?.SERVICEID) {
  114. var shr = [];
  115. var shyj = [];
  116. if (item.shlc.length > 1) {
  117. item.shlc.map((i, index) => {
  118. if (index != 0 && index != item.shlc.length - 1) {
  119. shr.push(i.USER_NAME)
  120. shyj.push(i.CHECKINFO)
  121. }
  122. })
  123. }
  124. var app = appList.find((i) => i.KEY == item.systemkey);
  125. resData.push({
  126. resInCarId: item.applyCarInfo.id,
  127. serviceid: item?.resInfo?.SERVICEID,
  128. zylx: type === 'MAP' ? '地图资源' : type === 'SCENE' ? '场景资源' : '文件资源',
  129. zymc: item.applyCarInfo.resName,
  130. yyxt: app?.NAME || '',
  131. sqsj: item.applyCarInfo.createtime,
  132. sqr: item.sqrname,
  133. shzt: item.shzt,
  134. shr: shr.join(','),
  135. shyj: shyj.join(','),
  136. })
  137. }
  138. }
  139. })
  140. console.log("资源中心申请库列表:", resData)
  141. resolve(resData)
  142. } else {
  143. resolve([])
  144. }
  145. }).catch((err) => {
  146. resolve([])
  147. })
  148. })
  149. }
  150. //注册表格
  151. const [registerTable, { reload, getRowSelection, getSelectRowKeys, clearSelectedRowKeys }] = useTable({
  152. title: '资源列表',
  153. api: getAllData, //数据
  154. // dataSource: [],
  155. columns: columns, //表头配置
  156. bordered: false,
  157. striped: false,
  158. useSearchForm: false, //开启搜索区域
  159. // formConfig: formConfig, //搜索字段配置
  160. actionColumn: {
  161. width: 120,
  162. title: '操作',
  163. dataIndex: 'action',
  164. slots: { customRender: 'action' },
  165. },
  166. rowSelection: {
  167. type: 'checkbox',
  168. getCheckboxProps: (record) => {
  169. if (record.shzt != '未提交' && record.shzt != '审核不通过') {
  170. return { disabled: true }
  171. } else {
  172. return null
  173. }
  174. }
  175. },
  176. pagination: {
  177. // pageSize: 10,
  178. hideOnSinglePage: false
  179. },
  180. rowKey: (record) => record.serviceid,
  181. canResize: true,
  182. showTableSetting: true, // 显示表格设置
  183. tableSetting: {
  184. redo: true,
  185. size: true,
  186. setting: false,
  187. fullScreen: false
  188. },
  189. maxHeight: 400,
  190. minHeight: 400,
  191. showIndexColumn: true,
  192. indexColumnProps: { fixed: 'left' },
  193. });
  194. //判断是否选中数据
  195. const hasSelected = computed(() => {
  196. const rowSelection = getRowSelection();
  197. return !(rowSelection.selectedRowKeys?.length === 1);
  198. });
  199. //重置查询
  200. const handleReset = () => {
  201. searchValue.value = '';
  202. selectValue.value = '';
  203. searchTime.value = '';
  204. reload();
  205. }
  206. //条件查询
  207. const handleSearch = () => {
  208. reload();
  209. }
  210. //移除资源
  211. const handleDelete = (record) => {
  212. Modal.confirm({
  213. title: '移出提示',
  214. icon: createVNode(ExclamationCircleOutlined),
  215. content: '确定移出该资源?',
  216. centered: true,
  217. okText: '确定',
  218. okType: 'danger',
  219. cancelText: '取消',
  220. onOk: (() => {
  221. let params = {
  222. idList: [record.resInCarId]
  223. }
  224. deleteResInCar(params, record).then(res => {
  225. reload();
  226. eventBus.emit('platListCenter')
  227. eventBus.emit('addResToCarEventBus')
  228. })
  229. })
  230. });
  231. }
  232. //添加申请
  233. const handleAdd = () => {
  234. console.log('开始申请');
  235. Modal.confirm({
  236. title: '申请提示',
  237. icon: createVNode(ExclamationCircleOutlined),
  238. content: '确定提交申请该资源?',
  239. centered: true,
  240. okText: '确定',
  241. cancelText: '取消',
  242. onOk: (() => {
  243. queryFlowInfoPage({
  244. page: 1,
  245. rows: 1000000
  246. }).then(flowRes => {
  247. const rowKeys = getSelectRowKeys();
  248. let ids = rowKeys.toString();
  249. // console.log(flowRes);
  250. let flag = 0
  251. flowRes.forEach(item => {
  252. if (item.FLOWNAME === judgeType(ids)) {
  253. flag = 1
  254. let params = {
  255. bussInfo: {
  256. bussname: judgeType(ids),//业务名称
  257. flowid: item.id,//流程id
  258. serverids: ids//资源id
  259. }
  260. }
  261. submitExamine(params).then(res => {
  262. if (res.resp_code === 0 && res.resp_msg === '提交成功') {
  263. message.success('申请成功')
  264. reload();
  265. } else {
  266. message.error('申请失败')
  267. }
  268. })
  269. }
  270. })
  271. clearSelectedRowKeys();
  272. !flag && message.info('没有对应流程,请联系管理员');
  273. })
  274. })
  275. });
  276. }
  277. const judgeType = (id) => {
  278. let resType = ''
  279. resType = id.indexOf('MR') > -1 ? '地图资源授权' : id.indexOf('ER') > -1 ? '场景资源授权' : '文件资源授权';
  280. // console.log(resType);
  281. return resType
  282. }
  283. // 关闭请求弹窗
  284. const onClose = (e) => {
  285. emit('closeModal')
  286. }
  287. //初始化请求所需数据
  288. onMounted(() => {
  289. })
  290. const [registerModal, { openModal }] = useModal();
  291. /**
  292. * 申请弹出框
  293. * @param record
  294. */
  295. function handleCreate() {
  296. var list = getSelectRowKeys();
  297. openModal(true, {
  298. isUpdate: false,
  299. sqzys: list
  300. });
  301. }
  302. /**
  303. * 申请弹出框
  304. * @param record
  305. */
  306. function applyHandleEdit(record) {
  307. if (record.serviceid) {
  308. openModal(true, {
  309. record,
  310. isUpdate: true,
  311. sqzys: [record.serviceid]
  312. });
  313. } else {
  314. message.error('选择的资源没有服务ID!')
  315. }
  316. }
  317. /**
  318. * 申请成功
  319. */
  320. function applyHandleSuccess() {
  321. reload();
  322. eventBus.emit('platListCenter')
  323. }
  324. return {
  325. props,
  326. registerModal,
  327. handleCreate,
  328. applyHandleEdit,
  329. applyHandleSuccess,
  330. // formRef,
  331. searchValue,
  332. selectValue,
  333. searchTime,
  334. statusOptions,
  335. hasSelected,
  336. ...toRefs(data),
  337. registerTable,
  338. handleReset,
  339. handleSearch,
  340. handleDelete,
  341. handleAdd,
  342. onClose
  343. };
  344. },
  345. });
  346. </script>
  347. <style lang="less" scoped>
  348. .modal-wrap {
  349. .action-content {
  350. padding: 20px;
  351. max-height: 800px;
  352. overflow: auto;
  353. background-color: #eff0f5;
  354. .top-search {
  355. width: 100%;
  356. height: 74px;
  357. border-radius: 6px;
  358. background: #FFFFFF;
  359. display: flex;
  360. justify-content: space-between;
  361. align-items: center;
  362. .left-search-input {
  363. margin-left: 20px;
  364. display: flex;
  365. .input {
  366. margin-right: 30px;
  367. span {
  368. margin-right: 10px;
  369. }
  370. }
  371. }
  372. .right-btns {
  373. margin-right: 20px;
  374. }
  375. }
  376. .bottom-table {
  377. margin-top: 20px;
  378. .basic-table {
  379. height: 100%;
  380. ::v-deep .ant-table-title {
  381. padding: 0 !important;
  382. .vben-basic-title {
  383. font-family: '阿里巴巴普惠体 2.0';
  384. font-size: 16px;
  385. font-weight: bold;
  386. color: #333333;
  387. }
  388. }
  389. }
  390. }
  391. }
  392. }
  393. </style>