ResHistoryVersionModal.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!-- 资源的历史版本查询弹窗 -->
  2. <template>
  3. <BasicModal :maskClosable="false" :width="1430" @register="registerModal" v-bind="$attrs" :title="title" centered
  4. :showOkBtn="false" :showCancelBtn="false" wrapClassName="res-history-version-modal" :footer="null">
  5. <div class="custom-content">
  6. <div class="right-header">
  7. <div class="search">
  8. <span class="label">资源名称:</span>
  9. <a-input v-model:value="searchValue" placeholder="输入关键字查询" allow-clear />
  10. </div>
  11. <div class="handle-btns">
  12. <a-button class="btn" @click="resetTable">重置</a-button>
  13. <a-button class="btn" type="primary" @click="searchTable">查询</a-button>
  14. </div>
  15. </div>
  16. <div class="right-body">
  17. <BasicTable @register="registerTable">
  18. <template #action="{ record }">
  19. <TableAction :actions="[
  20. {
  21. label: '选择',
  22. tooltip: '选择',
  23. onClick: handleSelectRes.bind(null, record),
  24. }
  25. ]" />
  26. </template>
  27. </BasicTable>
  28. </div>
  29. </div>
  30. </BasicModal>
  31. </template>
  32. <script>
  33. import { defineComponent, reactive, ref, onMounted, watch, computed } from 'vue';
  34. import { BasicModal, useModalInner } from '/@/components/Modal';
  35. // 导入表格组件,表格事件
  36. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  37. import { Button, message } from 'ant-design-vue';
  38. import { getResVersionList } from '/@/api/sys/version';
  39. import { session } from '/@/utils/Memory';
  40. import moment from 'moment';
  41. export default defineComponent({
  42. name: 'VersionResModal',
  43. components: { BasicModal, BasicTable, TableAction, Button },
  44. setup(_, { emit }) {
  45. const title = ref('');
  46. const currentType = ref('')
  47. const searchValue = ref('')
  48. const typeObj = {
  49. MR: "地图资源",
  50. ER: "场景资源",
  51. DR: "文件资源",
  52. SR: "组件服务",
  53. interface: "接口服务"
  54. }
  55. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  56. console.log(data)
  57. title.value = `【${typeObj[data.type]}】历史版本查询`
  58. currentType.value = data.type
  59. reload();
  60. });
  61. const getResData = () => {
  62. return new Promise((resolve, reject) => {
  63. let params = {
  64. isgl: 1,
  65. keyStr: searchValue.value,
  66. serviceType: currentType.value
  67. }
  68. getResVersionList(params).then(res => {
  69. if (res.resp_code === 0 && res.datas) {
  70. let resData = res.datas.pageData;
  71. resData.forEach(item => {
  72. item.type = typeObj[item.RESOURCE_TYPE]
  73. })
  74. resolve(resData)
  75. }
  76. else {
  77. resolve([])
  78. message.error(res.resp_msg)
  79. }
  80. })
  81. })
  82. }
  83. //表格列
  84. const columns = [
  85. {
  86. title: '资源类型',
  87. align: 'center',
  88. dataIndex: 'type',
  89. key: 'type'
  90. },
  91. {
  92. title: '资源名称',
  93. align: 'center',
  94. dataIndex: 'SERVICENAME',
  95. key: 'SERVICENAME'
  96. },
  97. {
  98. title: '版本',
  99. align: 'center',
  100. dataIndex: 'VERSION_NAME',
  101. key: 'VERSION_NAME'
  102. },
  103. {
  104. title: '版本号',
  105. align: 'center',
  106. dataIndex: 'VERSION',
  107. key: 'VERSION'
  108. },
  109. {
  110. title: '操作时间',
  111. align: 'center',
  112. dataIndex: 'MODIFY_DATE',
  113. key: 'MODIFY_DATE'
  114. },
  115. {
  116. title: '操作人',
  117. align: 'center',
  118. dataIndex: 'USER_NAME',
  119. key: 'USER_NAME'
  120. }
  121. ];
  122. const [
  123. registerTable,
  124. { reload, collapseAll, getRowSelection, getSelectRowKeys, setSelectedRowKeys },
  125. ] = useTable({
  126. title: '资源列表', //'菜单列表'
  127. api: getResData, //加载数据
  128. columns: columns,
  129. useSearchForm: false, //开启搜索区域
  130. bordered: false,
  131. showTableSetting: true, // 显示表格设置
  132. tableSetting: {
  133. redo: true,
  134. size: true,
  135. setting: false,
  136. fullScreen: false
  137. },
  138. showIndexColumn: true,
  139. pagination: {
  140. hideOnSinglePage: false
  141. },
  142. rowKey: (record) => record.SERVICEID,
  143. actionColumn: {
  144. width: 200,
  145. title: '操作',
  146. dataIndex: 'action',
  147. slots: { customRender: 'action' },
  148. }
  149. });
  150. //表格查询功能
  151. const searchTable = () => {
  152. reload()
  153. }
  154. //重置
  155. const resetTable = () => {
  156. searchValue.value = '';
  157. reload();
  158. }
  159. // 历史版本
  160. const handleSelectRes = (record) => {
  161. const detail = [
  162. {
  163. label: "资源类型",
  164. value: record.type
  165. },
  166. {
  167. label: "资源名称",
  168. value: record.SERVICENAME
  169. },
  170. {
  171. label: "版本名称",
  172. value: record.VERSION_NAME
  173. },
  174. {
  175. label: "版本号",
  176. value: record.VERSION
  177. },
  178. {
  179. label: "版本时间",
  180. value: record.MODIFY_DATE
  181. }
  182. ]
  183. const historyResId = record.SERVICEID;
  184. const historyVersionId = record.VERSION_ID;
  185. emit('select', { info: detail, resId: historyResId, versionId: historyVersionId });
  186. closeModal();
  187. }
  188. return {
  189. title,
  190. currentType,
  191. searchValue,
  192. registerModal,
  193. registerTable,
  194. resetTable,
  195. searchTable,
  196. handleSelectRes
  197. };
  198. },
  199. });
  200. </script>
  201. <style lang="less">
  202. .res-history-version-modal {
  203. .ant-modal-content {
  204. background-color: #eff0f5;
  205. .scroll-container .scrollbar__wrap {
  206. margin-bottom: 0 !important;
  207. }
  208. }
  209. }
  210. </style>
  211. <style lang="less" scoped>
  212. .custom-content {
  213. .right-header {
  214. margin-bottom: 10px;
  215. height: 74px;
  216. padding: 0 20px;
  217. display: flex;
  218. align-items: center;
  219. background-color: #ffffff;
  220. border-radius: 6px;
  221. justify-content: space-between;
  222. .search {
  223. display: flex;
  224. align-items: center;
  225. .label {
  226. width: 120px;
  227. }
  228. }
  229. .handle-btns {
  230. display: flex;
  231. align-items: center;
  232. .btn {
  233. margin-left: 10px;
  234. }
  235. }
  236. }
  237. .right-body {
  238. padding: 0 20px;
  239. height: calc(100% - 84px);
  240. background-color: #ffffff;
  241. border-radius: 6px;
  242. }
  243. }
  244. </style>