index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="__normal-page">
  3. <div class="__normal-content">
  4. <CusContent
  5. v-model:tableHead="tableHead"
  6. @handleReset="handleReset"
  7. @handleSearch="onSearch"
  8. >
  9. <template #fieldOut>
  10. <CusForm labelWidth="100px" @handleEnter="onSearch">
  11. <CusFormColumn
  12. label="席位编号:"
  13. v-model:param="queryForm.seatSerialNumber"/>
  14. <CusFormColumn
  15. label="单位:"
  16. link="select"
  17. v-model:param="queryForm.unitId"
  18. :options="$store.state.dictionary.deptList"/>
  19. <CusFormColumn
  20. label="提交人员:"
  21. v-model:param="queryForm.submitter"/>
  22. <CusFormColumn
  23. label="日志日期:"
  24. link="date"
  25. type="daterange"
  26. v-model:param="queryForm.dutyDate"/>
  27. <CusFormColumn
  28. label="提交时间:"
  29. link="datetime"
  30. type="datetimerange"
  31. v-model:param="queryForm.submitDate"/>
  32. <CusSearchButtons
  33. @handleReset="handleReset"
  34. @handleSearch="onSearch"
  35. />
  36. </CusForm>
  37. </template>
  38. <template #buttons>
  39. <!-- <div class="__cus-button_submit __hover" @click="onAdd">-->
  40. <!-- <SvgIcon name="add" size="16"/>新增-->
  41. <!-- </div>-->
  42. </template>
  43. <template #table>
  44. <CusTable
  45. v-loading="loading"
  46. ref="ref_cusTable"
  47. :tableData="queryResult.tableData"
  48. :tableHead="tableHead"
  49. :total="queryResult.total"
  50. :page="queryPage.pageNum"
  51. :pageSize="queryPage.pageSize"
  52. @handlePage="handlePage"
  53. >
  54. <template #do-column-value="{ scope }">
  55. <div class="__cus-table_do">
  56. <div class="__cus-table_do-green __hover" @click="onView(scope.row)">
  57. <SvgIcon name="view" size="16"/>查看
  58. </div>
  59. <div class="__cus-table_do-blue __hover" @click="onEdit(scope.row)">
  60. <SvgIcon name="edit" size="16"/>编辑
  61. </div>
  62. <div class="__cus-table_do-red __hover" @click="onDel(scope.row)">
  63. <SvgIcon name="del" size="16"/>删除
  64. </div>
  65. </div>
  66. </template>
  67. </CusTable>
  68. </template>
  69. </CusContent>
  70. </div>
  71. <DetailCom v-model:show="showDetail" :transfer="transfer" @refresh="refreshSearch"/>
  72. </div>
  73. </template>
  74. <script lang="ts">
  75. import {
  76. defineComponent,
  77. computed,
  78. onMounted,
  79. ref,
  80. reactive,
  81. watch,
  82. getCurrentInstance,
  83. ComponentInternalInstance,
  84. toRefs,
  85. nextTick
  86. } from 'vue'
  87. import {useStore} from 'vuex'
  88. import {useRouter, useRoute} from 'vue-router'
  89. import DetailCom from './detail.vue'
  90. import {ElMessage, ElMessageBox} from 'element-plus'
  91. export default defineComponent({
  92. name: '',
  93. components: {
  94. DetailCom
  95. },
  96. setup(props, {emit}) {
  97. const store = useStore();
  98. const router = useRouter();
  99. const route = useRoute();
  100. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  101. const state = reactive({
  102. // 加载中
  103. loading: false,
  104. // 查询分页参数
  105. queryPage: {
  106. pageNum: 1,
  107. pageSize: 10
  108. },
  109. // 查询结果
  110. queryResult: {
  111. total: 0,
  112. tableData: []
  113. },
  114. // 查询表单参数
  115. queryForm: <any>{},
  116. // 查询表单参数备份
  117. back_queryForm: {},
  118. // 表格表头
  119. tableHead: [
  120. {value: "title", label: "日志标题", show: true},
  121. {value: "seatSerialNumber", label: "席位编号", show: true},
  122. {value: "unitName", label: "单位", show: true},
  123. {value: "submitter", label: "提交人员", show: true},
  124. {value: "dutyTime", label: "日志日期", show: true, width: 180},
  125. {value: "submitTime", label: "提交时间", show: true, width: 180},
  126. {value: "do", label: "操作", show: true, popover: true, width: 260},
  127. ],
  128. showDetail: false,
  129. transfer: {}
  130. });
  131. const ref_cusTable = ref()
  132. // 获取字典
  133. const initDictionary = () => {
  134. store.dispatch('dictionary/LOAD_DEPT')
  135. }
  136. // 查询分页参数改变处理方法
  137. const handlePage = ({page, pageSize}: any) => {
  138. state.queryPage.pageNum = page
  139. state.queryPage.pageSize = pageSize
  140. handleSearch(page, pageSize)
  141. }
  142. // 列表刷新方法
  143. const refreshSearch = () => {
  144. state.queryPage.pageNum = 1
  145. handleSearch(state.queryPage.pageNum, state.queryPage.pageSize)
  146. }
  147. // 重置查询表单方法
  148. const handleReset = () => {
  149. state.queryForm = {}
  150. state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
  151. refreshSearch()
  152. }
  153. // 查询方法
  154. const handleSearch = (page = 1, pageSize = 10) => {
  155. const queryParams: any = {
  156. pageNum: page,
  157. pageSize: pageSize,
  158. }
  159. // 添加表单参数
  160. for (const [k, v] of Object.entries(state.back_queryForm)) {
  161. if (that.$util.isValue(v)) {
  162. if (k === 'unitId') {
  163. queryParams['unitName'] = store.state.dictionary.deptMap.get(v).organizationName
  164. } else if (k === 'dutyDate') {
  165. queryParams['beginDutyTime'] = v[0]
  166. queryParams['endDutyTime'] = v[1]
  167. } else if (k === 'submitDate') {
  168. queryParams['beginTime'] = v[0]
  169. queryParams['endTime'] = v[1]
  170. } else {
  171. queryParams[k] = v
  172. }
  173. }
  174. }
  175. state.loading = true
  176. that.$api.getDailyReportList(queryParams).then((res: any) => {
  177. if (res.code === 200) {
  178. state.queryResult.tableData = res.rows
  179. state.queryResult.total = res.total
  180. } else {
  181. ElMessage.error(res.message)
  182. }
  183. state.loading = false
  184. }).catch(() => {
  185. state.loading = false
  186. })
  187. }
  188. // 点击查询按钮后
  189. const onSearch = () => {
  190. ref_cusTable.value.resetFilter()
  191. state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
  192. refreshSearch()
  193. }
  194. const onAdd = () => {
  195. state.transfer = {
  196. method: 'add',
  197. }
  198. state.showDetail = true
  199. }
  200. const onEdit = (val) => {
  201. state.transfer = {
  202. method: 'edit',
  203. detail: val
  204. }
  205. state.showDetail = true
  206. }
  207. const onView = (val) => {
  208. state.transfer = {
  209. method: 'view',
  210. detail: val
  211. }
  212. state.showDetail = true
  213. }
  214. const onDel = (val) => {
  215. ElMessageBox.confirm(`是否删除${val.title}?`, "提示", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning",
  219. }).then(() => {
  220. state.loading = true
  221. that.$api.delDailyReportDelete({id: val.id}).then(res => {
  222. if (res.code === 200) {
  223. ElMessage.success(res.message)
  224. refreshSearch()
  225. } else {
  226. ElMessage.error(res.message)
  227. state.loading = false
  228. }
  229. }).catch(() => {
  230. state.loading = false
  231. })
  232. }).catch(() => {})
  233. }
  234. onMounted(() => {
  235. state.back_queryForm = JSON.parse(JSON.stringify(state.queryForm))
  236. initDictionary()
  237. refreshSearch()
  238. })
  239. return {
  240. ref_cusTable,
  241. ...toRefs(state),
  242. handleSearch,
  243. handlePage,
  244. handleReset,
  245. onSearch,
  246. onAdd,
  247. onEdit,
  248. onView,
  249. onDel,
  250. refreshSearch
  251. }
  252. },
  253. })
  254. </script>
  255. <style scoped lang="scss">
  256. </style>