index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36 ml-2">
  5. <el-select v-model="searchForm.projectId" block clearable placeholder="项目名称" size="large">
  6. <el-option v-for="item in projectType" :label="item.projectName" :value="item.projectId" />
  7. </el-select>
  8. </div>
  9. <div class="ml-4">
  10. <el-button type="primary" size="large" @click="searchClick">
  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" size="large" @click="toImportTempClick">
  24. <HcIcon name="delete-bin-2" />
  25. <span>草稿箱{{ draftNum > 0 ? `(${draftNum})` : '' }}</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 #tripDesc="{ row }">
  34. <span class="text-blue">{{ row.tripDesc }}</span>
  35. </template>
  36. <!-- <template #action="{row, index}">
  37. <el-button hc-btn type="primary" size="small">撤销</el-button>
  38. </template> -->
  39. <template #action="{ row, index }">
  40. <el-popconfirm title="是否确认撤销?" hide-icon @confirm="rowCancel(row)">
  41. <template #reference>
  42. <el-button
  43. size="small" type="primary"
  44. :disabled="row.status !== 1"
  45. :loading="row.isCancelLoading"
  46. >
  47. 撤销
  48. </el-button>
  49. </template>
  50. </el-popconfirm>
  51. </template>
  52. </HcTable>
  53. <template #action>
  54. <HcPages :pages="searchForm" @change="pageChange" />
  55. </template>
  56. <!-- 草稿箱弹窗 -->
  57. <HcDialog bg-color="#ffffff" widths="62rem" is-to-body :show="importModal" title="草稿箱" is-table @close="importModalClose">
  58. <el-alert title="3个月内未更新的草稿将被自动删除" type="warning" show-icon />
  59. <div class="table_box">
  60. <HcTable :column="drafttableColumn" :datas="drafttableData" ui="hc-test-drop-table" :loading="draftLoad">
  61. <template #action="{ row, index }">
  62. <el-button hc-btn type="primary" size="small" @click="editinfoClick(row)">
  63. 继续编辑
  64. </el-button>
  65. <el-button hc-btn type="primary" size="small" @click="delRowClick(row)">
  66. 删除
  67. </el-button>
  68. </template>
  69. </HcTable>
  70. </div>
  71. </HcDialog>
  72. </HcCard>
  73. </template>
  74. <script setup>
  75. import { onActivated, onMounted, ref, watch } from 'vue'
  76. import dayjs from 'dayjs'
  77. import 'dayjs/locale/zh-cn'
  78. import { useRouter } from 'vue-router'
  79. import businessApi from '~api/attendance/business-trip.js'
  80. import { getArrValue } from 'js-fast-way'
  81. import { getDictInfo, getProjectList } from '~api/other'
  82. import { delMessage } from '~uti/tools'
  83. const router = useRouter()
  84. onActivated(()=>{
  85. getProjectData()
  86. getTableData()
  87. getdraftTableData()
  88. })
  89. const tableColumn = [
  90. { key: 'tripDesc', name: '出差事由' },
  91. { key: 'projectName', name: '关联项目' },
  92. { key: 'duration', name: '实际出勤天数' },
  93. { key: 'durationAll', name: '出差天数' },
  94. { key: 'fellowTravelerUserNames', name: '同行人' },
  95. { key: 'approvalResultName', name: '审批结果' },
  96. { key: 'approvalStatusName', name: '审批状态' },
  97. { key: 'createName', name: '创建人' },
  98. { key: 'createTime', name: '创建时间' },
  99. { key: 'action', name: '操作', width: '90', align: 'center', fixed: 'right' },
  100. ]
  101. const tableData = ref([
  102. { name: '名称1', id:1 },
  103. { name: '名称2' },
  104. { name: '名称3' },
  105. ])
  106. const searchForm = ref({
  107. current: 1, size: 20, total: 0,
  108. })
  109. //项目类型
  110. const projectType = ref([
  111. ])
  112. //获取项目数据
  113. const getProjectData = async () => {
  114. const { error, code, data } = await getProjectList()
  115. //判断状态
  116. if (!error && code === 200) {
  117. projectType.value = getArrValue(data)
  118. } else {
  119. projectType.value = []
  120. }
  121. }
  122. //分页被点击
  123. const pageChange = ({ current, size }) => {
  124. searchForm.value.current = current
  125. searchForm.value.size = size
  126. getTableData()
  127. }
  128. const tableLoading = ref(false)
  129. const getTableData = async () => {
  130. tableLoading.value = true
  131. const { error, code, data } = await businessApi.getPage(searchForm.value)
  132. tableLoading.value = false
  133. if (!error && code === 200) {
  134. tableData.value = getArrValue(data['records'])
  135. searchForm.value.total = data['total'] || 0
  136. } else {
  137. tableData.value = []
  138. searchForm.value.total = 0
  139. }
  140. }
  141. //搜索
  142. const searchClick = () => {
  143. searchForm.value.current = 1
  144. getTableData()
  145. }
  146. //重置搜索表单
  147. const resetClick = () => {
  148. searchForm.value = { current: 1, size: 20, total: 0 }
  149. }
  150. const defaultTime = ref([
  151. new Date(2000, 1, 1, 0, 0, 0),
  152. new Date(2000, 2, 1, 23, 59, 59),
  153. ])
  154. //草稿箱
  155. //草稿箱数据
  156. const draftNum = ref(0)
  157. const importModal = ref(false)
  158. const importModalClose = ()=>{
  159. importModal.value = false
  160. }
  161. const drafttableColumn = [
  162. { key: 'title', name: '标题' },
  163. { key: 'updateTime', name: '更新时间' },
  164. { key: 'action', name: '操作', widths:120 },
  165. ]
  166. const drafttableData = ref([
  167. { name: '名称1', text: '2023-5-23 15:21:08' },
  168. { name: '名称1', text: '2023-5-23 15:21:08' },
  169. ])
  170. const draftLoad = ref(false)
  171. const getdraftTableData = async () => {
  172. draftLoad.value = true
  173. const { error, code, data } = await businessApi.getDraftList()
  174. draftLoad.value = false
  175. if (!error && code === 200) {
  176. drafttableData.value = getArrValue(data)
  177. draftNum.value = getArrValue(data).length
  178. } else {
  179. drafttableData.value = []
  180. }
  181. }
  182. const toImportTempClick = ()=>{
  183. importModal.value = true
  184. getdraftTableData()
  185. }
  186. //编辑出差申请
  187. const addinfoClick = ()=>{
  188. router.push({
  189. name: 'attendance-business-trip-info',
  190. query: {
  191. type: 'add',
  192. },
  193. })
  194. }
  195. const editinfoClick = (row)=>{
  196. importModal.value = false
  197. router.push({
  198. name: 'attendance-business-trip-info',
  199. query: {
  200. id: row.emdraftIds,
  201. type: 'draft',
  202. },
  203. })
  204. }
  205. //查看
  206. const rowClick = (row) => {
  207. router.push({
  208. name: 'attendance-business-trip-info',
  209. query: {
  210. id: row.id,
  211. type: 'view',
  212. },
  213. })
  214. }
  215. //撤销
  216. const rowCancel = async (row) => {
  217. row.isCancelLoading = true
  218. const { error, code, msg } = await businessApi.cancel({
  219. id: row.id,
  220. })
  221. //判断状态
  222. row.isCancelLoading = false
  223. if (!error && code === 200) {
  224. window.$message?.success(msg)
  225. getTableData().then()
  226. }
  227. }
  228. //删除
  229. const delRowClick = async (row) => {
  230. delMessage(async () => {
  231. const { error, code, data, msg } = await businessApi.remove({ groupId:row.groupId })
  232. if (!error && code === 200) {
  233. window.$message.success(msg)
  234. getdraftTableData().then()
  235. } else {
  236. window.$message?.error(msg)
  237. }
  238. })
  239. }
  240. </script>
  241. <style lang='scss' scoped>
  242. </style>