index.vue 8.2 KB

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