index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36 ml-2">
  5. <el-select v-model="searchForm.peoplename" block clearable placeholder="项目名称" size="large">
  6. <el-option v-for="item in peopleoption" :label="item.name" :value="item.key"/>
  7. </el-select>
  8. </div>
  9. <div class="ml-4">
  10. <el-button type="primary" @click="searchClick" size="large">
  11. <HcIcon name="search-2"/>
  12. <span>搜索</span>
  13. </el-button>
  14. </div>
  15. <div class="ml-2">
  16. <el-button size="large" @click="resetClick">
  17. <HcIcon name="close-circle"/>
  18. <span>重置</span>
  19. </el-button>
  20. </div>
  21. </template>
  22. <template #extra>
  23. <el-button type="warning" @click="toImportTempClick" size="large">
  24. <HcIcon name="delete-bin-2"/>
  25. <span>草稿箱</span>
  26. </el-button>
  27. <el-button type="primary" size="large" class="ml-2" @click="addinfoClick">
  28. <HcIcon name="add"/>
  29. <span>新增出差申请</span>
  30. </el-button>
  31. </template>
  32. <HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading">
  33. <template #action="{row, index}">
  34. <el-button hc-btn type="primary" size="small">撤销</el-button>
  35. </template>
  36. </HcTable>
  37. <template #action>
  38. <HcPages :pages="searchForm" @change="pageChange"></HcPages>
  39. </template>
  40. <!--草稿箱弹窗-->
  41. <HcDialog bgColor="#ffffff" widths="62rem" isToBody :show="importModal" title="草稿箱" @close="importModalClose" isTable >
  42. <el-alert title="3个月内未更新的草稿将被自动删除" type="warning" show-icon/>
  43. <div class="table_box">
  44. <HcTable :column="drafttableColumn" :datas="drafttableData" ui="hc-test-drop-table" isRowDrop isSort @row-drop="rowDropTap" @row-sort="rowSortTap">
  45. <template #action="{row, index}">
  46. <el-button hc-btn type="primary" size="small" @click="editinfoClick(row)">继续编辑</el-button>
  47. <el-button hc-btn type="primary" size="small">删除</el-button>
  48. </template>
  49. </HcTable>
  50. </div>
  51. </HcDialog>
  52. </HcCard>
  53. </template>
  54. <script setup>
  55. import {ref, watch,onMounted} from 'vue'
  56. import dayjs from "dayjs"
  57. import 'dayjs/locale/zh-cn'
  58. import {useRouter} from 'vue-router'
  59. import {getTokenHeader} from "~src/api/request/header";
  60. import businessApi from '~api/attendance/business-trip.js';
  61. const router = useRouter()
  62. onMounted(()=>{
  63. getTableData()
  64. })
  65. const tableColumn = [
  66. {key: 'name', name: '出差事由'},
  67. {key: 'key2', name: '关联项目'},
  68. {key: 'key4', name: '实际出勤天数'},
  69. {key: 'key5', name: '出差天数'},
  70. {key: 'key6', name: '同行人'},
  71. {key: 'key7', name: '审批结果'},
  72. {key: 'key8', name: '审批状态'},
  73. {key: 'key9', name: '创建人'},
  74. {key: 'key10', name: '创建时间'},
  75. {key: 'action', name: '操作' }
  76. ]
  77. const tableData = ref([
  78. {name: '名称1',id:1},
  79. {name: '名称2', },
  80. {name: '名称3', }
  81. ])
  82. const searchForm = ref({
  83. name: '',
  84. current: 1, size: 20, total: 0
  85. })
  86. const peopleoption=ref([
  87. {name: '张三', key: '1'},
  88. {name: '李四', key: '2'},
  89. ])
  90. //分页被点击
  91. const pageChange = ({current, size}) => {
  92. searchForm.value.current = current
  93. searchForm.value.size = size
  94. getTableData()
  95. }
  96. const tableLoading=ref(false)
  97. const getTableData = async() => {
  98. tableLoading.value = true
  99. const {error, code, data} = await businessApi.getPage(searchForm.value)
  100. tableLoading.value = false
  101. if (!error && code === 200) {
  102. tableData.value = getArrValue(data)
  103. searchForm.value.total = data['total'] || 0
  104. } else {
  105. tableData.value = []
  106. searchForm.value.total = 0
  107. }
  108. }
  109. //搜索
  110. const searchClick = () => {
  111. searchForm.value.current = 1;
  112. getTableData()
  113. }
  114. //重置搜索表单
  115. const resetClick = () => {
  116. searchForm.value = {current: 1, size: 20, total: 0}
  117. }
  118. const defaultTime = ref([
  119. new Date(2000, 1, 1, 0, 0, 0),
  120. new Date(2000, 2, 1, 23, 59, 59),
  121. ])
  122. //导入数据弹窗
  123. const importModal=ref(false)
  124. const importModalClose=()=>{
  125. importModal.value=false
  126. }
  127. const drafttableColumn = [
  128. {key: 'name', name: '标题'},
  129. {key: 'text', name: '更新时间'},
  130. {key: 'action', name: '操作',widths:120},
  131. ]
  132. const drafttableData = ref([
  133. {name: '名称1', text: '2023-5-23 15:21:08', },
  134. {name: '名称1', text: '2023-5-23 15:21:08', },
  135. ])
  136. // 行拖拽
  137. const rowDropTap = (rows) => {
  138. tableData.value = rows
  139. }
  140. // 点击排序
  141. const rowSortTap = (rows) => {
  142. tableData.value = rows
  143. }
  144. const toImportTempClick=()=>{
  145. importModal.value=true
  146. }
  147. //编辑出差申请
  148. const addinfoClick=()=>{
  149. router.push({
  150. name: 'attendance-business-trip-info',
  151. query: {
  152. type: 'add'
  153. }
  154. })
  155. }
  156. const editinfoClick=(row)=>{
  157. importModal.value=false
  158. router.push({
  159. name: 'attendance-business-trip-info',
  160. query: {
  161. type: 'edit'
  162. }
  163. })
  164. }
  165. </script>
  166. <style lang='scss' scoped>
  167. </style>