index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="bm-main-box">
  3. <div class="flex items-center">
  4. <div class="bm-main-box-title">{{ $route.meta.title }}</div>
  5. <div class="ml-auto flex items-center gap-[var(--czr-gap)]">
  6. <CzrForm class="bm-filter" label-width="0px" @handleEnter="onSearch">
  7. <CzrFormColumn
  8. width="6.68rem"
  9. class="__czr-table-form-column"
  10. :span="24"
  11. label-width="0px"
  12. v-model:param="state.query.form.modeType"
  13. link="select"
  14. :options="[]"
  15. placeholder="应用状态"
  16. />
  17. <CzrFormColumn
  18. width="6.68rem"
  19. class="__czr-table-form-column"
  20. :span="24"
  21. label-width="0px"
  22. v-model:param="state.query.form.status"
  23. link="select"
  24. :options="[]"
  25. placeholder="应用类型"
  26. />
  27. <CzrFormColumn
  28. width="15.63rem"
  29. class="__czr-table-form-column"
  30. :span="24"
  31. label-width="0px"
  32. v-model:param="state.text"
  33. placeholder="输入关键词以检索"
  34. :prefix-icon="Search"
  35. />
  36. <CzrButton type="add" @click="onAdd" />
  37. </CzrForm>
  38. </div>
  39. </div>
  40. <div
  41. class="mt-[1rem] flex-1 overflow-hidden"
  42. v-loading="state.query.loading"
  43. >
  44. <CzrTableCard
  45. class="table-card"
  46. :page="state.query.page.pageNum"
  47. :pageSize="state.query.page.pageSize"
  48. :total="state.query.result.total"
  49. :data="state.query.result.data"
  50. @handlePage="onPage"
  51. :col="4"
  52. >
  53. <template #model="{ row, index }">
  54. <div
  55. class="model __hover"
  56. @click="
  57. $router.push({
  58. name: 'a36ccd46-f399-4bf6-8db9-157ca8d3e8c8',
  59. params: {
  60. id: row.id,
  61. },
  62. })
  63. "
  64. >
  65. <div class="flex">
  66. <img
  67. src="@/assets/images/app/app-default-logo.png"
  68. class="mr-[var(--czr-gap)] h-[3.25rem] w-[3.25rem]"
  69. />
  70. <div class="flex flex-1 flex-col justify-between overflow-hidden">
  71. <div class="flex">
  72. <template v-if="index % 2 === 0">
  73. <div
  74. class="rounded-xs bg-[#5AD8A6] px-2.5 py-1 text-xs text-white"
  75. >
  76. 已发布
  77. </div>
  78. <div
  79. class="ml-auto rounded-2xl bg-gradient-to-r from-[#C3E3FC] to-[#86C4FF] px-3 py-1 text-xs text-[#0876FF]"
  80. >
  81. 简洁
  82. </div>
  83. </template>
  84. <template v-else>
  85. <div
  86. class="rounded-xs bg-[#A7ADB9] px-2.5 py-1 text-xs text-white"
  87. >
  88. 草稿
  89. </div>
  90. <div
  91. class="ml-auto rounded-2xl bg-gradient-to-r from-[#E0DAFF] to-[#BABCFF] px-3 py-1 text-xs text-[#1E3F92]"
  92. >
  93. 高级
  94. </div>
  95. </template>
  96. </div>
  97. <div class="text-[1.25rem] font-bold text-[#2E3238]" v-title>
  98. {{ row.name }}
  99. </div>
  100. </div>
  101. </div>
  102. <div
  103. class="mt-3 flex items-center gap-[var(--czr-gap)] text-[0.75rem] text-[#6F7889]"
  104. >
  105. <div>(用户名称)</div>
  106. <div>|</div>
  107. <div>(时间)</div>
  108. <div class="ml-auto">
  109. <el-dropdown :teleported="true">
  110. <SvgIcon name="omit" />
  111. <template #dropdown>
  112. <el-dropdown-menu>
  113. <el-dropdown-item @click="onCopy(row)"
  114. >创建副本</el-dropdown-item
  115. >
  116. <el-dropdown-item @click="onEdit(row)"
  117. >设置</el-dropdown-item
  118. >
  119. <el-dropdown-item @click="onDel(row)"
  120. >删除</el-dropdown-item
  121. >
  122. <el-dropdown-item @click="onMonitor(row)"
  123. >监测(发布的才有)</el-dropdown-item
  124. >
  125. </el-dropdown-menu>
  126. </template>
  127. </el-dropdown>
  128. </div>
  129. </div>
  130. </div>
  131. </template>
  132. </CzrTableCard>
  133. </div>
  134. <detailCom
  135. v-model:show="state.detail.show"
  136. :transfer="state.detail.transfer"
  137. @refresh="onSearch"
  138. />
  139. </div>
  140. </template>
  141. <script setup lang="ts">
  142. import { getCurrentInstance, onMounted, reactive, ref, watch } from 'vue'
  143. import { Search } from '@element-plus/icons-vue'
  144. import { debounce } from 'lodash'
  145. import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
  146. import { ElMessage } from 'element-plus'
  147. import detailCom from './detail.vue'
  148. import {
  149. pluginDel,
  150. pluginGetInstanceList,
  151. pluginUpdateStatus,
  152. } from '@/api/modules/model'
  153. import { YMDHms } from '@/utils/czr-util'
  154. import SvgIcon from '@/components/SvgIcon/index.vue'
  155. const AppStore = useAppStore()
  156. const DialogStore = useDialogStore()
  157. const DictionaryStore = useDictionaryStore()
  158. const emit = defineEmits([])
  159. const props = defineProps({})
  160. const { proxy }: any = getCurrentInstance()
  161. const state: any = reactive({
  162. text: '',
  163. query: {
  164. init: false,
  165. loading: false,
  166. page: {
  167. pageNum: 1,
  168. pageSize: 20,
  169. },
  170. form: {},
  171. formReal: {},
  172. result: {
  173. total: 0,
  174. data: [],
  175. },
  176. },
  177. detail: {
  178. show: false,
  179. transfer: {},
  180. },
  181. })
  182. const setText = debounce((v) => {
  183. state.query.form.keyword = v
  184. }, 1000)
  185. watch(
  186. () => state.text,
  187. (n) => {
  188. setText(n)
  189. },
  190. )
  191. watch(
  192. () => state.query.form,
  193. (n) => {
  194. if (state.query.init) {
  195. onSearch()
  196. }
  197. },
  198. { deep: true },
  199. )
  200. const onPage = (pageNum, pageSize) => {
  201. setTimeout(() => {
  202. state.query.init = true
  203. }, 100)
  204. state.query.page = {
  205. pageNum: pageNum,
  206. pageSize: pageSize,
  207. }
  208. const params = {
  209. page: state.query.page.pageNum,
  210. size: state.query.page.pageSize,
  211. }
  212. // 添加表单参数
  213. for (const [k, v] of Object.entries(state.query.formReal)) {
  214. if (proxy.$czrUtil.isValue(v)) {
  215. params[k] = v
  216. }
  217. }
  218. state.query.loading = true
  219. pluginGetInstanceList(params)
  220. .then(({ data }: any) => {
  221. state.query.result.total = data.total
  222. state.query.result.data = data.records
  223. })
  224. .catch(() => {})
  225. .finally(() => {
  226. state.query.loading = false
  227. })
  228. }
  229. const onSearch = () => {
  230. state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
  231. onPage(1, state.query.page.pageSize)
  232. }
  233. const onReset = () => {
  234. state.query.page = {
  235. pageNum: 1,
  236. pageSize: 20,
  237. }
  238. state.query.form = {}
  239. onSearch()
  240. }
  241. const onAdd = () => {
  242. state.detail.transfer = {
  243. mode: 'add',
  244. }
  245. state.detail.show = true
  246. }
  247. const onCopy = (row) => {
  248. state.detail.transfer = {
  249. mode: 'copy',
  250. id: row.id,
  251. }
  252. state.detail.show = true
  253. }
  254. const onEdit = (row) => {
  255. state.detail.transfer = {
  256. mode: 'edit',
  257. id: row.id,
  258. }
  259. state.detail.show = true
  260. }
  261. const onDel = (row: any) => {
  262. DialogStore.confirm({
  263. title: '删除确认',
  264. content: `请确认是否删除`,
  265. onSubmit: () => {
  266. // pluginDel(row.id)
  267. // .then(() => {
  268. // ElMessage.success('删除成功!')
  269. // })
  270. // .catch(() => {})
  271. // .finally(() => {
  272. // onSearch()
  273. // })
  274. },
  275. })
  276. }
  277. const onMonitor = (row) => {}
  278. onMounted(() => {
  279. initDictionary()
  280. onReset()
  281. })
  282. const initDictionary = () => {}
  283. </script>
  284. <style lang="scss" scoped>
  285. .model {
  286. width: 100%;
  287. background-image: url('@/assets/images/model/model-icon-7.png');
  288. background-repeat: no-repeat;
  289. background-size: 100% 100%;
  290. padding: 1rem;
  291. border-radius: var(--czr-gap);
  292. box-shadow: 0rem 0.25rem 0.63rem 0rem rgba(40, 83, 247, 0.05);
  293. border: var(--czr-border);
  294. display: flex;
  295. flex-direction: column;
  296. }
  297. </style>