ResCarModal.vue 17 KB

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