ResCarModal.vue 15 KB

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