index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="table-box">
  3. <div class="card table-main">
  4. <!-- 表格头部 操作按钮 -->
  5. <div class="table-header">
  6. <div class="header-button-lf">
  7. <el-form :model="pageable" label-width="auto" :inline="true">
  8. <el-form-item label="自动站:">
  9. <SelectItem :select-data="selectedData" :select-list="platformList" :is-checkbox="true" @update:selectedItems="selectedItems" style="width: 200px"> </SelectItem>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" @click="handleQuery"> 查询 </el-button>
  13. <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
  14. <!-- <el-button style="margin-left: 10px" type="primary" plain @click="handleAdd"> 新增 </el-button>-->
  15. </el-form-item>
  16. </el-form>
  17. </div>
  18. </div>
  19. <!-- 表格主体 -->
  20. <el-table stripe ref="tableRef" :border="true" :data="showList" size="small">
  21. <el-table-column align="left" label="序号" width="80px" :show-overflow-tooltip="true">
  22. <template #default="scope">
  23. {{ (pageable.pageNum - 1) * pageable.pageSize + scope.$index + 1 }}
  24. </template>
  25. </el-table-column>
  26. <template v-for="item in columns" :key="item">
  27. <el-table-column v-bind="item" :align="item.align ?? 'left'" :reserve-selection="item.type == 'selection'" :show-overflow-tooltip="true">
  28. <template #default="scope">
  29. <template v-if="item.prop === 'address'">
  30. {{scope.row['as_province']}}
  31. {{scope.row['as_city']}}
  32. {{scope.row['as_area']}}
  33. {{scope.row['as_address']}}
  34. </template>
  35. <template v-if="item.prop === 'map_level'">
  36. {{scope.row.map_level+1}}
  37. </template>
  38. <template v-if="item.prop === 'view_mode'">
  39. {{findLabelByValue(typeList,scope.row.view_mode)}}
  40. </template>
  41. <template v-if="item.prop === 'operation'">
  42. <el-tooltip
  43. class="box-item"
  44. effect="dark"
  45. content="编辑"
  46. placement="top"
  47. >
  48. <el-button type="primary" link @click="handleUpdate(scope.row)">
  49. <el-icon >
  50. <Edit />
  51. </el-icon>
  52. </el-button>
  53. </el-tooltip>
  54. <!-- <el-tooltip-->
  55. <!-- class="box-item"-->
  56. <!-- effect="dark"-->
  57. <!-- content="删除"-->
  58. <!-- placement="top"-->
  59. <!-- >-->
  60. <!-- <el-button type="primary" link @click="handleDelete(scope.row)">-->
  61. <!-- <el-icon >-->
  62. <!-- <Delete />-->
  63. <!-- </el-icon>-->
  64. <!-- </el-button>-->
  65. <!-- </el-tooltip>-->
  66. </template>
  67. </template>
  68. </el-table-column>
  69. </template>
  70. <!-- 无数据 -->
  71. <template #empty>
  72. <div class="table-empty">
  73. <slot name="empty">
  74. <img src="@/assets/images/notData.png" alt="notData" />
  75. <div>暂无数据</div>
  76. </slot>
  77. </div>
  78. </template>
  79. </el-table>
  80. <!-- 分页组件 -->
  81. <Pagination :pageable="pageable" :handle-size-change="handleSizeChange" :handle-current-change="handleCurrentChange" />
  82. </div>
  83. <!-- 添加或修改对话框 -->
  84. <el-dialog v-if="dialog.visible" :title="dialog.title" v-model="dialog.visible" width="1600px" append-to-body :close-on-click-modal="false">
  85. <el-tabs tab-position="left" class="demo-tabs" style="height: 700px">
  86. <el-tab-pane label="基本参数">
  87. <ParametersBasic :select-data="rowItem"></ParametersBasic>
  88. </el-tab-pane>
  89. <el-tab-pane label="观测要素">
  90. <Translation :select-data="rowItem" :sensorList="sensorList"></Translation>
  91. </el-tab-pane>
  92. <el-tab-pane label="仪器检定证">
  93. <VerificationCertificate :select-data="rowItem" :sensorList="sensorList"></VerificationCertificate>
  94. </el-tab-pane>
  95. <el-tab-pane label="阈值设置">
  96. <Threshold :select-data="rowItem"></Threshold>
  97. </el-tab-pane>
  98. <el-tab-pane label="保障策略设置">
  99. <StrategySafeguard :select-data="rowItem"></StrategySafeguard>
  100. </el-tab-pane>
  101. <el-tab-pane label="编报项目设置">
  102. <Newspapers :select-data="rowItem"></Newspapers>
  103. </el-tab-pane>
  104. </el-tabs>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script setup lang="ts" name="useProTable">
  109. import Pagination from "@/components/ProTable/components/Pagination.vue";
  110. import Translation from "./components/translation.vue";
  111. import SelectItem from "@/components/SelectItem/index.vue";
  112. import VerificationCertificate from "./components/verificationCertificate.vue";
  113. import Threshold from "./components/threshold.vue";
  114. import Newspapers from "./components/newspapers.vue";
  115. import ParametersBasic from "./components/parametersBasic.vue";
  116. import StrategySafeguard from "./components/strategySafeguard.vue";
  117. import {ref, reactive, computed, onMounted} from "vue";
  118. import { ColumnProps } from "@/components/ProTable/interface";
  119. import { ElMessageBox } from 'element-plus'
  120. import {useUserStore} from "@/stores/modules/user";
  121. import { getYallSensorList } from "@/api/modules/allData";
  122. // 获取传感器字典
  123. const sensorList = ref<any>([]);
  124. const getSensorList = async () => {
  125. const { data } = await getYallSensorList();
  126. sensorList.value = data.list
  127. };
  128. //搜索站号
  129. const selectedData= ref([])
  130. const userStore = useUserStore();
  131. //下拉数据
  132. const platformList =ref<any>(computed(() => userStore.stations))
  133. //列表展示原始数据
  134. const processTableData = ref(computed(() => userStore.stations));
  135. //列表展示查询分页后数据
  136. const initList = computed(() => {
  137. const start = (pageable.value.pageNum - 1) * pageable.value.pageSize;
  138. const end = start + pageable.value.pageSize;
  139. // 根据分页参数截取数据
  140. return processTableData.value.slice(start, end);
  141. });
  142. // 响应式引用,存储初始列表的副本
  143. const showList = ref([]);
  144. const pageable = ref<any>({
  145. as_code: '',
  146. pageNum: 1,
  147. pageSize: 20,
  148. total: platformList.value.length
  149. });
  150. // 查询功能
  151. const handleQuery = () => {
  152. pageable.value.pageNum = 1; // 重置到第一页
  153. const filteredData = processTableData.value.filter(item =>
  154. item.as_code.includes(pageable.value.as_code)
  155. );
  156. pageable.value.total = filteredData.length; // 更新总数
  157. // 确保通过 .value 修改 ref 的值
  158. showList.value = filteredData;
  159. console.log(showList.value);
  160. };
  161. // 重置功能
  162. const resetQuery = () => {
  163. selectedData.value = []
  164. pageable.value.as_code = ''; // 清除查询条件
  165. pageable.value.pageNum = 1; // 重置到第一页
  166. pageable.value.total = processTableData.value.length; // 重置总数
  167. // 确保通过 .value 修改 ref 的值
  168. showList.value = processTableData.value.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageNum * pageable.value.pageSize);
  169. };
  170. // 每页条数改变
  171. const handleSizeChange = (val: number) => {
  172. pageable.value.pageSize = val;
  173. pageable.value.pageNum = 1; // 重置到第一页
  174. updateShowList();
  175. };
  176. // 当前页改变
  177. const handleCurrentChange = (val: number) => {
  178. pageable.value.pageNum = val;
  179. updateShowList();
  180. };
  181. // 更新显示列表
  182. const updateShowList = () => {
  183. if (pageable.value.as_code) {
  184. const filteredData = processTableData.value.filter(item =>
  185. item.as_code.includes(pageable.value.as_code)
  186. );
  187. showList.value = filteredData.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageNum * pageable.value.pageSize);
  188. } else {
  189. showList.value = processTableData.value.slice((pageable.value.pageNum - 1) * pageable.value.pageSize, pageable.value.pageNum * pageable.value.pageSize);
  190. }
  191. };
  192. const selectedItems =(data)=>{
  193. if(data.length>0){
  194. pageable.value.as_code = data[0]
  195. }
  196. };
  197. // 表格配置项
  198. const columns = reactive<ColumnProps[]>([
  199. { prop: "as_depart", label: "部别" },
  200. { prop: "as_name", label: "站名" },
  201. { prop: "as_code", label: "站号" },
  202. { prop: "map_level", label: "地图层级" },
  203. { prop: "address", label: "地址" },
  204. { prop: "as_lon", label: "经度" },
  205. { prop: "as_lat", label: "纬度" },
  206. { prop: "as_auditor", label: "预审员"},
  207. { prop: "check_leader", label: "测试组长"},
  208. { prop: "station_leader", label: "台长"},
  209. { prop: "view_mode", label: "观测方式"},
  210. { prop: "operation", label: "操作", width:150,align: 'center' }
  211. ]);
  212. const dialog = reactive<any>({
  213. visible: false,
  214. title: ''
  215. });
  216. const formRef = ref<any>();
  217. const initFormData = ref<any>(
  218. {
  219. code: "",
  220. type: "",
  221. name: "",
  222. startTime:"",
  223. endTime:"",
  224. remark: ""
  225. }
  226. );
  227. const form = ref<any>({...initFormData});
  228. /** 新增按钮操作 */
  229. const handleAdd = () => {
  230. reset();
  231. dialog.visible = true;
  232. dialog.title = "新增台站";
  233. }
  234. const rowItem = ref({})
  235. /** 修改按钮操作 */
  236. const handleUpdate = async (row?: any) => {
  237. reset();
  238. rowItem.value = row
  239. dialog.visible = true;
  240. dialog.title = "编辑台站";
  241. }
  242. /** 取消按钮 */
  243. const cancel = () => {
  244. reset();
  245. dialog.visible = false;
  246. }
  247. /** 表单重置 */
  248. const reset = () => {
  249. form.value = { ...initFormData };
  250. formRef.value?.resetFields();
  251. }
  252. /** 提交按钮 */
  253. const submitForm = () => {
  254. formRef.value?.validate(async (valid: boolean) => {
  255. if (valid) {
  256. dialog.visible = false;
  257. }
  258. });
  259. }
  260. /** 删除按钮操作 */
  261. const handleDelete = async (row?: any) => {
  262. ElMessageBox.confirm('是否确认删除编号为"' + row.b + '"的数据项?', {
  263. confirmButtonText: '删除',
  264. cancelButtonText: '取消',
  265. type: 'warning',
  266. title:'删除数据',
  267. draggable: true
  268. })
  269. .then(() => {
  270. })
  271. .catch(() => {
  272. })
  273. }
  274. function findLabelByValue(noticeTypeList, value) {
  275. const item = noticeTypeList.find(item => item.value === value);
  276. return item ? item.label : null;
  277. }
  278. const typeList= [
  279. {
  280. value: 0,
  281. label: '人工值班',
  282. },
  283. {
  284. value: 1,
  285. label: '自动值班',
  286. },
  287. {
  288. value: 2,
  289. label: '自动值班',
  290. }
  291. ]
  292. onMounted(() => {
  293. getSensorList()
  294. // 在组件挂载时,将计算属性 initList 的值赋值给 showList
  295. showList.value = [...initList.value];
  296. });
  297. </script>