PlatformTable.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="form">
  3. <el-form ref="ruleFormRef" :model="ruleForm" inline label-width="60px">
  4. <!-- <el-form-item label="姓名:" prop="nickName" style="margin-top: 15px;">
  5. <el-input v-model="ruleForm.nickName" placeholder="请输入姓名!" style="width: 150px;"></el-input>
  6. </el-form-item>
  7. <el-form-item label="工号:" prop="staffNo" style="margin-top: 15px;">
  8. <el-input v-model="ruleForm.staffNo" placeholder="请输入工号!" style="width: 150px;"></el-input>
  9. </el-form-item> -->
  10. <el-input
  11. v-model="searchValue"
  12. style="max-width: 251px; margin-right: 50px"
  13. :placeholder="'请输入' + searchLabel"
  14. >
  15. <template #prepend>
  16. <el-select v-model="searchLabel" style="width: 74px">
  17. <el-option value="姓名" />
  18. <el-option value="工号" />
  19. </el-select>
  20. </template>
  21. </el-input>
  22. <el-form-item label="部门:" prop="dept" style="margin-bottom: 0; margin-right: 0">
  23. <el-select v-model="ruleForm.dept" placeholder="请选择部门" style="width: 200px">
  24. <el-option
  25. v-for="item in departmentList"
  26. :key="item.deptId"
  27. :value="item.deptName"
  28. :label="item.deptName"
  29. >
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-button
  34. type="primary"
  35. @click="submitForm(ruleFormRef)"
  36. style="width: 65px; height: 32px; position: absolute; right: 134px"
  37. >搜 索</el-button
  38. >
  39. <el-button
  40. @click="resetForm(ruleFormRef)"
  41. style="width: 65px; height: 32px; position: absolute; right: 57px"
  42. >重 置</el-button
  43. >
  44. </el-form>
  45. <el-table
  46. style="width: 100%; margin-top: 18px"
  47. stripe
  48. :data="tableData"
  49. highlight-current-row
  50. :default-sort="{ prop: 'todayVisits', order: 'descending' }"
  51. >
  52. <el-table-column label="姓名" prop="nickName" align="center"></el-table-column>
  53. <el-table-column label="工号" prop="staffNo" align="center"></el-table-column>
  54. <el-table-column label="部门" prop="deptName" align="center"></el-table-column>
  55. <el-table-column
  56. :label="'当日' + props.tableLabel"
  57. prop="todayVisits"
  58. sortable
  59. align="right"
  60. ></el-table-column>
  61. <el-table-column
  62. :label="'本月' + tableLabel"
  63. prop="monthVisits"
  64. sortable
  65. align="right"
  66. ></el-table-column>
  67. <el-table-column
  68. :label="'累计' + tableLabel"
  69. prop="totalVisits"
  70. sortable
  71. align="right"
  72. ></el-table-column>
  73. <el-table-column v-if="tableLabel === '访问次数'" label="访问次数统计图" align="center">
  74. <img
  75. style="display: inline-block; margin-right: 20px"
  76. src="@/assets/icons/chart-bar.png"
  77. alt=""
  78. />
  79. <img style="display: inline-block" src="@/assets/icons/chart-line.png" alt="" />
  80. </el-table-column>
  81. </el-table>
  82. <!-- <el-pagination v-model="currentPage" v-model:currentPageSize="currentPageSize" :page-sizes="[10, 20, 50, 100, 200]"
  83. layout="->, total,sizes,prev,pager,next,jumper" :total="total" @size-change="handeSizeChange"
  84. @current-change="handleCurrentPageChange" /> -->
  85. </div>
  86. <!-- <TableEcharts v-model="dialogVisible" :dialog-visible="dialogVisible" :userId="userId"
  87. :current-day-chart="currentDayData" :current-month-chart="currentMonthData" :all-datas-chart="currentAllData"
  88. :close-dialog="closeDialog">
  89. </TableEcharts> -->
  90. </template>
  91. <script setup lang="ts">
  92. import { ref } from 'vue';
  93. import { defineProps } from 'vue';
  94. import { FormInstance } from 'element-plus';
  95. import { DepartMentModel } from '@/api/datamanagement/dataplatform';
  96. import { TableModel } from '@/api/datamanagement/dataplatform';
  97. // import { DepartMentModel, Records, Visits, VisitsModel, getDeptList } from '@/api/datamanagement/dataplatform';
  98. const searchLabel = ref('姓名');
  99. const searchValue = ref('');
  100. const props = defineProps<{
  101. tableData: TableModel[];
  102. tableLabel: string;
  103. }>();
  104. export interface FormModelCommon {
  105. dept: string;
  106. nickName: string;
  107. staffNo: string;
  108. }
  109. const ruleForm = ref<FormModelCommon>({
  110. dept: '',
  111. nickName: '',
  112. staffNo: '',
  113. });
  114. const ruleFormRef = ref<FormInstance>();
  115. const departmentList = ref<DepartMentModel[]>([]);
  116. // 搜索数据
  117. function submitForm(formE1: FormInstance | undefined) {
  118. console.log('搜索数据');
  119. if (!formE1) return;
  120. // formE1.validate((valid, fields) => {
  121. // if (valid) {
  122. // getPersonalVisits(ruleForm.value)
  123. // }
  124. // else {
  125. // console.log('error submit!', fields);s
  126. // }
  127. // })
  128. }
  129. // 重置表单
  130. function resetForm(formE1: FormInstance | undefined) {
  131. console.log('重置表单');
  132. if (!formE1) return;
  133. // formE1.resetFields()
  134. // console.log('resetForm')
  135. // queryData();
  136. }
  137. // const props = defineProps<{ type: string }>()
  138. // const props = defineProps<{
  139. // queryData: (d1: number, d2: number) => Promise<Visits<Records>>,
  140. // currentDayData: (d: number) => Promise<VisitsModel[]>,
  141. // currentMonthData: (d: number) => Promise<VisitsModel[]>,
  142. // currentAllData: (d: number) => Promise<VisitsModel[]>,
  143. // getPersonalVisits: (d1: number | undefined, d2: string, d3: number, d4: number, d5: string) => Promise<Visits<Records>>,
  144. // }>();
  145. // const dialogVisible = ref(false);//控制弹框显示
  146. // const currentPage = ref(1);
  147. // const currentPageSize = ref(10);
  148. // const total = ref(11);
  149. // const tableData = ref<TableModel[]>()
  150. // const userId = ref(10014);
  151. // const getDepartmentList = () => {
  152. // getDeptList().then((res) => {
  153. // departmentList.value = res;
  154. // console.log('department:', res)
  155. // });
  156. // };
  157. // 查询数据列表
  158. // async function queryData() {
  159. // const res = await props.queryData(currentPage.value, currentPageSize.value);
  160. // console.log('tablecommon-querydata:', res);
  161. // tableData.value = res.records;
  162. // console.log('tablecommon-querydata1:', tableData.value);
  163. // total.value = res.totalRow;
  164. // }
  165. // 根据指定参数查询数据-搜索数据
  166. // function queryDataByParams() {
  167. // props.queryDataByParams().then(res => {
  168. // console.log(res)
  169. // })
  170. // // emit('queryDataByParams', data);
  171. // }
  172. // interface FormTable {
  173. // text: string,
  174. // dept: string,
  175. // }
  176. // // 翻页
  177. // function handleCurrentPageChange(val: number) {
  178. // currentPage.value = val
  179. // console.log('currentPage:' + currentPage.value)
  180. // queryData();
  181. // }
  182. // // 页数
  183. // function handeSizeChange(val: number) {
  184. // currentPageSize.value = val
  185. // console.log('currentPageSize:' + currentPageSize.value)
  186. // queryData()
  187. // }
  188. // function closeDialog() {
  189. // dialogVisible.value = false;
  190. // }
  191. // // 查询今日访问次数
  192. // function currentDayData(userId: number) {
  193. // console.log('table-common-currentDayData:', userId)
  194. // return props.currentDayData(userId).then(res => {
  195. // console.log('table-common-currentdaydata:', res)
  196. // return res
  197. // })
  198. // }
  199. // // 查询本月访问次数
  200. // function currentMonthData(userId: number) {
  201. // console.log('table-common-currentMonthData:', userId)
  202. // return props.currentMonthData(userId).then(res => {
  203. // console.log('table-common-currentmonthdata:', res);
  204. // return res
  205. // })
  206. // }
  207. // // 查询累计访问次数
  208. // function currentAllData(userId: number) {
  209. // return props.currentAllData(userId).then(res => {
  210. // console.log('table-common:', res);
  211. // return res;
  212. // })
  213. // }
  214. // // 查询个人访问次数-搜索数据
  215. // function getPersonalVisits(data: FormModelCommon) {
  216. // const departId = ref();
  217. // departmentList.value.forEach(item => {
  218. // if (item.deptName === data.dept) {
  219. // departId.value = item.deptId;
  220. // }
  221. // })
  222. // const newParam = {
  223. // pageNumber: currentPage.value,
  224. // pageSize: currentPageSize.value,
  225. // nickName: data.nickName,
  226. // // deptId: data.dept === BoardDeptEnum.all ? undefined : data.dept,
  227. // deptId: departId.value,
  228. // staffNo: data.staffNo,
  229. // }
  230. // console.log('getPersonalVisits:', newParam);
  231. // props.getPersonalVisits(newParam.deptId, newParam.nickName, newParam.pageNumber, newParam.pageSize, newParam.staffNo).then(res => {
  232. // console.log('table-common-getPersonalVisits:', res)
  233. // tableData.value = res.records;
  234. // })
  235. // }
  236. // // 打开数据表
  237. // function openDialog(row: TableModel) {
  238. // console.log('tablecommon-opendialog');
  239. // console.log(row.userId);
  240. // // tbData.value=row;
  241. // userId.value = row.userId;
  242. // dialogVisible.value = true;
  243. // // currentDayData();
  244. // }
  245. // onMounted(() => {
  246. // queryData()
  247. // getDepartmentList();
  248. // })
  249. </script>
  250. <style scoped>
  251. .form {
  252. /* width: 1100px; */
  253. margin-top: 18px;
  254. }
  255. .el-pagination {
  256. margin-top: 30px;
  257. }
  258. </style>