index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <hc-sys id="app-sys" class="hc-ledger-page" :isNavBar="false">
  3. <view id="nav-bar" class="bg-white hc-tab-bar">
  4. <scroll-view scroll-x class="nav" scroll-with-animation :scroll-left="scrollLeft">
  5. <template v-for="(item, index) in tabList" :key="index">
  6. <view class="cu-item" :class="item.primaryKeyId === tabKey?'text-blue cur':''" @click="tabSelect(item, index)">
  7. {{item.title}}
  8. </view>
  9. </template>
  10. </scroll-view>
  11. </view>
  12. <view id="date-bar" class="hc-calendar-bar">
  13. <uni-calendar insert :showMonth="false" :selected="calendarSelected" @change="calendarChange" @monthSwitch="calendarSwitch" />
  14. </view>
  15. <!--内容区域-->
  16. <view class="hc-content-bar hc-zindex" :style="[bottomStyle, contentStyle]">
  17. <view class="arrow-bar" @click="isCollapseUnfold">
  18. <text class="i-ri-arrow-down-double-line icon" v-if="isCollapse"/>
  19. <text class="i-ri-arrow-up-double-line icon" v-else/>
  20. </view>
  21. <scroll-view class="h-full" scroll-y>
  22. <view v-for="(item, index) in timeFormData" :key="index" class="time-form-item">
  23. <view class="time">{{index+1}}、{{item.recordTime}}</view>
  24. <view class="name">{{item.createUserName}}</view>
  25. <view>
  26. <text class="text-blue" @click="handleTableQuery(item)">查看</text>
  27. <template v-if="!(item.status === 1 || item.status === 2)">
  28. <text class="ml-2 text-orange" @click="toReportPage(item)">上报</text>
  29. </template>
  30. <template v-if="(item.status === 1 || item.status === 2)">
  31. <text class="ml-2 text-red" v-if="userInfo.user_id == item.createUser" @click.stop="handleAbolish(item)">废除</text>
  32. <text class="ml-2" style="color: #d1d1d1;" v-else>废除</text>
  33. </template>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. <!--底部操作栏-->
  39. <HcTabbarBlock :height="80"/>
  40. <hc-tabbars id="tab-bar">
  41. <button type="primary" @click="fillReport">立即填报</button>
  42. </hc-tabbars>
  43. </hc-sys>
  44. </template>
  45. <script setup>
  46. import {ref, getCurrentInstance} from "vue";
  47. import {onLoad, onReady} from '@dcloudio/uni-app'
  48. import mainApi from '~api/ledger/index';
  49. import {useAppStore} from "@/store";
  50. import {deepClone, getArrValue, isString} from "js-fast-way";
  51. import {errorToast, querySelect, showModal, successToast, toPdfPreview} from "@/utils/tools";
  52. import dayjs from "dayjs";
  53. //初始变量
  54. const store = useAppStore()
  55. const instance = getCurrentInstance().proxy
  56. const contractInfo = ref(store.contractInfo);
  57. const userInfo = ref(store.userInfo);
  58. const projectId = ref(store.projectId);
  59. const contractId = ref(store.contractId);
  60. //页面启动完成
  61. onLoad(() => {
  62. fullDate.value = dayjs().format('YYYY-MM-DD')
  63. fullYear.value = dayjs().format('YYYY')
  64. getDataApi()
  65. })
  66. onReady(() => {
  67. setContentStyle()
  68. })
  69. //设置样式
  70. const bottomStyle = ref({}) // 距离底部
  71. const setContentStyle = async () => {
  72. const {height: appHeight } = await querySelect(instance, 'app-sys')
  73. const {height: navHeight } = await querySelect(instance, 'nav-bar')
  74. const {height: dateHeight } = await querySelect(instance, 'date-bar')
  75. const {height: tabHeight } = await querySelect(instance, 'tab-bar')
  76. bottomStyle.value = { bottom: tabHeight + 'px' }
  77. // 展开高度
  78. const unfold_height = appHeight - tabHeight
  79. // #ifdef H5
  80. unfoldHeight.value = { height: (unfold_height - (navHeight * 4)) + 'px' }
  81. // #endif
  82. // #ifdef APP-PLUS
  83. unfoldHeight.value = { height: (unfold_height - (navHeight * 7)) + 'px' }
  84. // #endif
  85. contentStyle.value = deepClone(unfoldHeight.value)
  86. //收起高度
  87. const collapse_height = appHeight - dateHeight - tabHeight
  88. // #ifdef H5
  89. collapseHeight.value = { height: (collapse_height - navHeight)+ 'px' }
  90. // #endif
  91. // #ifdef APP-PLUS
  92. collapseHeight.value = { height: (collapse_height - (navHeight * 3.5)) + 'px' }
  93. // #endif
  94. }
  95. //获取接口数据
  96. const getDataApi= async () => {
  97. await queryLogList()
  98. queryLogTimeTreeList().then()
  99. getSubmitLogDateList().then()
  100. }
  101. //获取tab数据
  102. const tabList = ref([])
  103. const tabItem = ref({})
  104. const queryLogList = async () => {
  105. const { data } = await mainApi.queryLogList({
  106. projectId: projectId.value,
  107. contractId: contractId.value,
  108. })
  109. const dataArr = getArrValue(data)
  110. if (dataArr.length > 0) {
  111. tabList.value = dataArr
  112. tabItem.value = dataArr[0]
  113. tabKey.value = dataArr[0]?.primaryKeyId
  114. } else {
  115. tabList.value = []
  116. tabItem.value = {}
  117. tabKey.value = ''
  118. }
  119. }
  120. //tab切换
  121. const tabKey = ref('')
  122. const scrollLeft = ref(0)
  123. const tabSelect = async (item, index) => {
  124. tabItem.value = item
  125. tabKey.value = item?.primaryKeyId
  126. scrollLeft.value = (index - 1) * 60
  127. uni.showLoading({title: '获取数据中...', mask: true});
  128. await queryLogTimeTreeList()
  129. await getSubmitLogDateList()
  130. uni.hideLoading()
  131. }
  132. //日历变量
  133. const calendarSelected = ref([])
  134. const getSubmitLogDateList = async () => {
  135. if (fullYear.value && tabKey.value) {
  136. const { data } = await mainApi.getSubmitLogDateList({
  137. projectId: projectId.value,
  138. contractId: contractId.value,
  139. primaryKeyId: tabKey.value,
  140. year: fullYear.value,
  141. })
  142. //处理数据
  143. let newArr = [], res = getArrValue(data)
  144. res.forEach((item)=>{
  145. newArr.push({ date: item })
  146. })
  147. calendarSelected.value = newArr
  148. } else {
  149. calendarSelected.value = []
  150. }
  151. }
  152. //切换年月
  153. const fullYear = ref('')
  154. const calendarSwitch = ({year}) => {
  155. if (year !== fullYear.value) {
  156. fullYear.value = year
  157. getSubmitLogDateList()
  158. }
  159. }
  160. //选择日期
  161. const fullDate = ref('')
  162. const calendarChange = ({fulldate, year}) => {
  163. if (fulldate !== fullDate.value) {
  164. fullDate.value = fulldate
  165. queryLogTimeTreeList()
  166. }
  167. if (year !== fullYear.value) {
  168. fullYear.value = year
  169. getSubmitLogDateList()
  170. }
  171. }
  172. //获取填报记录
  173. const timeFormData = ref([])
  174. const queryLogTimeTreeList = async () => {
  175. const { data } = await mainApi.queryLogTimeTreeList({
  176. contractId: contractId.value || '',
  177. nodePrimaryKeyId: tabKey.value,
  178. time: fullDate.value,
  179. })
  180. timeFormData.value = getArrValue(data)
  181. }
  182. //查看
  183. const handleTableQuery = async (item) => {
  184. uni.showLoading({title: '获取pdf文件中...', mask: true});
  185. const {excelId, primaryKeyId} = tabItem.value
  186. const { error, code, data } = await mainApi.getBussPdfInfo({
  187. contractId: contractId.value || '',
  188. pkeyId: excelId,
  189. nodePrimaryKeyId: primaryKeyId,
  190. recordTime: fullDate.value,
  191. theLogId: ""
  192. })
  193. const resData = isString(data) ? data || '' : ''
  194. uni.hideLoading();
  195. if (!error && code === 200 && resData) {
  196. toPdfPreview(resData)
  197. } else {
  198. errorToast('暂无PDF,无法预览')
  199. }
  200. }
  201. //上报
  202. const toReportPage = ({createUser, recordTime}) => {
  203. const {primaryKeyId, title} = tabItem.value, {real_name} = userInfo.value
  204. //路由跳转
  205. uni.navigateTo({
  206. url: '/pages/report/report',
  207. events:{
  208. finish: (data) => {
  209. queryLogTimeTreeList();
  210. }
  211. },
  212. success:(res) => {
  213. res.eventChannel.emit('reportProps', {
  214. type: "log",
  215. typeData: primaryKeyId,
  216. projectId: projectId.value,
  217. contractId: contractId.value,
  218. taskName: `${recordTime} ${title} ${real_name}`,
  219. url: 'contractLog/startTaskTheLog',
  220. addition: {
  221. nodePrimaryKeyId: primaryKeyId,
  222. recordTime: recordTime,
  223. userId: createUser,
  224. },
  225. })
  226. }
  227. });
  228. }
  229. //废除
  230. const handleAbolish = async (item) => {
  231. const res = await showModal({
  232. title: '废除上报',
  233. content: '请谨慎考虑后,是否确定废除',
  234. })
  235. if (!res) return
  236. uni.showLoading({title: '废除上报中...', mask: true});
  237. const {primaryKeyId} = tabItem.value
  238. const { error, code } = await mainApi.theLogOneAbolish({
  239. projectId: projectId.value,
  240. contractId: contractId.value,
  241. nodePrimaryKeyId: primaryKeyId,
  242. recordTime: item.recordTime
  243. })
  244. uni.hideLoading();
  245. if (!error && code === 200) {
  246. successToast('废除成功')
  247. queryLogTimeTreeList().then()
  248. } else {
  249. errorToast('废除失败')
  250. }
  251. }
  252. //展开收缩
  253. const collapseHeight = ref({}) // 收起高度
  254. const unfoldHeight = ref({}) // 展开高度
  255. const isCollapse = ref(true) // 是否展开
  256. const contentStyle = ref({}) // 设置高度
  257. const isCollapseUnfold = () => {
  258. if (isCollapse.value) {
  259. contentStyle.value = deepClone(collapseHeight.value)
  260. isCollapse.value = false
  261. } else {
  262. contentStyle.value = deepClone(unfoldHeight.value)
  263. isCollapse.value = true
  264. }
  265. }
  266. //立即填报
  267. const fillReport = () => {
  268. const {excelId, primaryKeyId, title, nodeType} = tabItem.value
  269. const {real_name} = userInfo.value
  270. uni.navigateTo({
  271. url: '/pages/ledger/editTable?node=' + encodeURIComponent(JSON.stringify({
  272. projectId: projectId.value ?? '',
  273. contractId: contractId.value ?? '',
  274. excelId: excelId ?? '',
  275. pkeyId: primaryKeyId ?? '',
  276. title: title ?? '',
  277. date: fullDate.value ?? '',
  278. nodeType: nodeType,
  279. taskName: `${fullDate.value} ${title} ${real_name}`,
  280. }))
  281. });
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. page {
  286. background: #EFEFF4;
  287. height: 100%;
  288. }
  289. </style>
  290. <style lang="scss">
  291. @import "@/style/ledger/index.scss";
  292. </style>