Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div>
  3. <crud-template ref="crudRef" class="as-weight" :submit-state="false" :home-data="field" :tableData="tableData"
  4. @btnSearch="btnSearch" @CurrentChange="handleCurrentChange" @importData="importData" @download="downloadHandle"
  5. @refreshLeft="refreshLeft" @add="Adds" @cancel="cancel" @submit="submitAdd" @handleEdit="handleEdit" @handleDelete="deleteHandle">
  6. <template #search>
  7. <el-input maxlength="60" v-trim clearable v-model="searchForm.version" style="width: 200px"
  8. placeholder="请输入版本号" />
  9. <el-select clearable v-model="searchForm.status" style="width: 200px;" placeholder="状态">
  10. <el-option v-for="item in ENABLE_STATUS" :key="item.value" :label="item.label" :value="item.value" />
  11. </el-select>
  12. <el-date-picker unlink-panels v-model="value1" type="daterange" range-separator="到" start-placeholder="发布日期始"
  13. end-placeholder="发布日期止" format="YYYY-MM-DD" value-format="YYYY-MM-DD" @change="dateChangeHandle" style="width: 250px"/>
  14. </template>
  15. <!-- 状态 -->
  16. <template #status="item">
  17. <el-switch :disabled="!IsPermission(route, 'STAET_LIST')"
  18. :model-value="item.scope.row.status === 'ENABLE' || item.scope.row.status === '启用'"
  19. active-color="#13ce66" inactive-color="#ff4949"
  20. @change="(value) => handleBeforeChange(value, item.scope.row.id, item.scope.row)">
  21. </el-switch>
  22. </template>
  23. </crud-template>
  24. </div>
  25. </template>
  26. <script setup lang="ts">
  27. import {ref, onMounted, watch, nextTick, toRaw, computed} from 'vue'
  28. import CrudTemplate from '@/crud/index.vue'
  29. import BaseService from '@/utils/baseService' //引入接口请求
  30. import {
  31. ElMessage,
  32. } from 'element-plus' //提示
  33. import { useRoute } from 'vue-router'
  34. import { IsPermission } from '@/router/routerUtil'
  35. import $storeinitData from "@/store/initData";
  36. //或取路由传入过来的对象数据
  37. const route = useRoute()
  38. const crudRef = ref()
  39. const value1 = ref()
  40. let tableData: any = ref([])
  41. const itemStartValue = ref(1)
  42. //查询参数
  43. const searchForm = ref({})
  44. let formLabelWidth = '150px';
  45. const ENABLE_STATUS = computed(() => {
  46. return $storeinitData.state.dictData['ENABLE_DISABLE_STATUS'] || []
  47. })
  48. const field = ref({
  49. tabSize: "small", //Table 的尺寸 large / default /small (默认default)
  50. searchShow: IsPermission(route, 'QUERY_BASE'), //是否显示搜索模块(默认false) IsPermission(route, 'QUERY_BASE')
  51. border: true, //是否添加边框(默认false)
  52. dialogCustom: false, //自定义Dialog (默认false)
  53. dialogFooter: false, //隐藏弹窗页脚显示 (默认false)
  54. dialogWidth: "40%", //dialog宽度 (默认40%)
  55. dialogInfoWidth: "60%",
  56. crudShow: true, //是否显示CURD操作栏 (默认true)
  57. crudChildShow: true, //是否显示CURD子操作栏 (默认true)
  58. paginStart: true, //是否显示分页查询 (默认false)
  59. dataListLoading: false,
  60. paging: {
  61. pageSize: 10,
  62. currentPage: 1,
  63. total: 0
  64. },
  65. crud: {
  66. add: IsPermission(route, 'ADD_BASE'),
  67. edit: false,
  68. delete: false,
  69. derive: false,
  70. search: false,
  71. refresh: false,
  72. },
  73. searchOperation: {
  74. isDownload: false,
  75. isAdd: false,
  76. isTransferMachine: false,
  77. },
  78. tableSize: -1,
  79. operateShow: true, //是否为表格添加操作栏(默认true)
  80. operateTitle: "操作", //操作栏标题(默认为"")
  81. operateFixed: true, //操作栏是否固定(默认false)
  82. operateWidth: "200", //操作栏宽度
  83. operate: {
  84. info: IsPermission(route, 'INFO_LIST'), //是否编辑(默认true) IsPermission(route, 'INFO_LIST')
  85. edit: IsPermission(route, 'EDIT_LIST'), //是否编辑(默认true) IsPermission(route, 'EDIT_LIST')
  86. delete: IsPermission(route, 'DEL_LIST'), //是否删除(默认true) IsPermission(route, 'DEL_LIST')
  87. announcement: false, // 公告
  88. remark: false, // 详情
  89. forbidden: false, // 禁用
  90. enable: false, // 启用
  91. authorization: false, // 授权
  92. cancel: false, // 取消订单
  93. writeOff: false, // 注销
  94. make: false, // 补缴
  95. },
  96. extend: [
  97. {
  98. label: "序号",
  99. type: "index", //类型:selection,index,expand
  100. width: "50", //表头宽度
  101. },
  102. ],
  103. field: [
  104. {
  105. prop: "version",
  106. label: "版本号",
  107. width: "100",
  108. form: {
  109. hideEdit: false,
  110. formLabelWidth: formLabelWidth,
  111. type: 'input',
  112. required: true,
  113. }
  114. },
  115. {
  116. prop: "publisher",
  117. label: "发布人",
  118. form: {
  119. hideEdit: true,
  120. width: '90%',
  121. formLabelWidth: formLabelWidth,
  122. type: 'input',
  123. }
  124. },
  125. {
  126. prop: "releaseTime",
  127. label: "发布时间",
  128. width: "140",
  129. form: {
  130. hideEdit: true,
  131. width: '90%',
  132. formLabelWidth: formLabelWidth,
  133. type: 'input',
  134. }
  135. },
  136. {
  137. prop: "url",
  138. label: "下载地址",
  139. form: {
  140. required: true,
  141. width: '90%',
  142. formLabelWidth: formLabelWidth,
  143. type: 'upload',
  144. accept: '.apk',
  145. placeholder: '请上传APP安装包',
  146. }
  147. },
  148. {
  149. prop: "status",
  150. label: "状态",
  151. slotSet: true,
  152. slotSetName: 'status',
  153. // form: {
  154. // formLabelWidth: formLabelWidth,
  155. // type: 'select',
  156. // hideEdit: false,
  157. // width: '90%',
  158. // listData: ENABLE_STATUS,
  159. // }
  160. },
  161. {
  162. prop: "isUpLevel",
  163. label: "是否强制更新",
  164. width: "80",
  165. form: {
  166. formLabelWidth: formLabelWidth,
  167. type: 'select',
  168. required: true,
  169. listData: [
  170. {
  171. label: '否',
  172. value: '0',
  173. },
  174. {
  175. label: '是',
  176. value: '1',
  177. },
  178. ],
  179. }
  180. },
  181. {
  182. prop: "message",
  183. label: "描述",
  184. form: {
  185. width: '90%',
  186. formLabelWidth: formLabelWidth,
  187. type: 'input',
  188. itemType: 'textarea',
  189. rows: 5,
  190. maxlength: '500', //文本限制输入长度
  191. }
  192. },
  193. ],
  194. })
  195. onMounted(() => {
  196. getList()
  197. })
  198. function dateChangeHandle(val: any) {
  199. if (val) {
  200. searchForm.value.startTime = val[0] + " 00:00:00";
  201. searchForm.value.endTime = val[1] + " 23:59:59";
  202. } else {
  203. searchForm.value.startTime = "";
  204. searchForm.value.endTime = "";
  205. }
  206. }
  207. //获取列表
  208. function getList() {
  209. if(!IsPermission(route, 'QUERY_BASE')){
  210. ElMessage.error('您没有权限,请联系管理员!')
  211. return
  212. }
  213. crudRef.value.tableLoding = true
  214. let params: any = {
  215. pageNo: field.value.paging.currentPage,
  216. pageSize: field.value.paging.pageSize,
  217. }
  218. //赋值查询参数
  219. let searchFormList = { ...searchForm.value }
  220. for (let key in searchFormList) {
  221. if (searchFormList[key]) {
  222. params[key] = searchFormList[key]
  223. }
  224. }
  225. BaseService.postN('/managew/api/operation/appVersion/page', params).then((res: any) => {
  226. if (res && res.code === 0) {
  227. //数据转换
  228. let bizContent = res.data
  229. let data = bizContent.result || []
  230. //数据渲染
  231. tableData.value = data
  232. crudRef.value.tableLoding = false
  233. //分页总数
  234. field.value.paging.total = bizContent.totalCount
  235. }
  236. })
  237. }
  238. const Adds = () => {
  239. itemStartValue.value = 1
  240. }
  241. //表单编辑按钮
  242. function handleEdit(idx: any, row: any) {
  243. itemStartValue.value = 2
  244. }
  245. // 添加
  246. const submitAdd = (data: any) => {
  247. request(data, itemStartValue.value)
  248. }
  249. const request = (data: any, type: any) => {
  250. //操作类型 1新增 2修改
  251. BaseService.postN(type == 1 ? '/managew/api/operation/appVersion/add' : '/managew/api/operation/appVersion/update', data).then((res: any) => {
  252. if (res && res.code === 0) {
  253. getList()
  254. crudRef.value.reset();
  255. crudRef.value.dialogFormVisible = false;
  256. ElMessage.success('操作成功')
  257. }
  258. })
  259. }
  260. // 删除
  261. const deleteHandle = (idx: any, row: any) => {
  262. BaseService.postN('/managew/api/operation/appVersion/delete', row).then((res: any) => {
  263. if (res && res.code === 0) {
  264. getList()
  265. crudRef.value.reset();
  266. crudRef.value.dialogFormVisible = false;
  267. } else {
  268. ElMessage.error(res.message)
  269. }
  270. })
  271. }
  272. //切换按钮
  273. function handleBeforeChange(value: boolean, id: string, row: any) {
  274. const status = value ? 'ENABLE' : 'DISABLE'
  275. const statusText = value ? '启用' : '禁用'
  276. BaseService.post('/managew/api/operation/appVersion/updateStatus', {
  277. id: id,
  278. status: status
  279. }).then((res: any) => {
  280. if (res && res.code === 0) {
  281. // 更新本地数据
  282. row.status = status
  283. getList()
  284. ElMessage.success(statusText + "成功");
  285. } else {
  286. ElMessage.error(res.message || statusText + "失败")
  287. }
  288. }).catch(() => {
  289. ElMessage.error(statusText + "失败")
  290. })
  291. }
  292. function downloadHandle() {
  293. }
  294. // 搜索按钮
  295. function btnSearch() {
  296. field.value.paging.currentPage = 1
  297. getList()
  298. }
  299. //分页
  300. function handleCurrentChange(val: number) {
  301. field.value.paging.currentPage = val
  302. getList()
  303. }
  304. // 搜索重置
  305. function refreshLeft() {
  306. searchForm.value = {}
  307. getList()
  308. }
  309. // 取消
  310. function cancel() {
  311. }
  312. </script>
  313. <style scoped>
  314. :deep(.my-content){
  315. word-break: break-all;
  316. }
  317. </style>