index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. if (item.pdfUrl) {
  185. toPdfPreview(item.pdfUrl).then()
  186. return false
  187. }
  188. uni.showLoading({title: '获取pdf文件中...', mask: true});
  189. const {excelId, primaryKeyId} = tabItem.value
  190. const { error, code, data } = await mainApi.getBussPdfInfo({
  191. contractId: contractId.value,
  192. pkeyId: excelId,
  193. nodePrimaryKeyId: primaryKeyId,
  194. recordTime: fullDate.value,
  195. theLogId: ""
  196. })
  197. const resData = isString(data) ? data ?? '' : ''
  198. uni.hideLoading();
  199. if (!error && code === 200 && resData) {
  200. toPdfPreview(resData).then()
  201. } else {
  202. errorToast('暂无PDF,无法预览')
  203. }
  204. }
  205. //上报
  206. const toReportPage = ({createUser, recordTime}) => {
  207. const {primaryKeyId, title} = tabItem.value, {real_name} = userInfo.value
  208. //路由跳转
  209. uni.navigateTo({
  210. url: '/pages/report/report',
  211. events:{
  212. finish: (data) => {
  213. queryLogTimeTreeList();
  214. }
  215. },
  216. success:(res) => {
  217. res.eventChannel.emit('reportProps', {
  218. type: "log",
  219. typeData: primaryKeyId,
  220. projectId: projectId.value,
  221. contractId: contractId.value,
  222. taskName: `${recordTime} ${title} ${real_name}`,
  223. url: 'contractLog/startTaskTheLog',
  224. addition: {
  225. nodePrimaryKeyId: primaryKeyId,
  226. recordTime: recordTime,
  227. userId: createUser,
  228. },
  229. })
  230. }
  231. });
  232. }
  233. //废除
  234. const handleAbolish = async (item) => {
  235. const res = await showModal({
  236. title: '废除上报',
  237. content: '请谨慎考虑后,是否确定废除',
  238. })
  239. if (!res) return
  240. uni.showLoading({title: '废除上报中...', mask: true});
  241. const {primaryKeyId} = tabItem.value
  242. const { error, code } = await mainApi.theLogOneAbolish({
  243. projectId: projectId.value,
  244. contractId: contractId.value,
  245. nodePrimaryKeyId: primaryKeyId,
  246. recordTime: item.recordTime
  247. })
  248. uni.hideLoading();
  249. if (!error && code === 200) {
  250. successToast('废除成功')
  251. queryLogTimeTreeList().then()
  252. } else {
  253. errorToast('废除失败')
  254. }
  255. }
  256. //展开收缩
  257. const collapseHeight = ref({}) // 收起高度
  258. const unfoldHeight = ref({}) // 展开高度
  259. const isCollapse = ref(true) // 是否展开
  260. const contentStyle = ref({}) // 设置高度
  261. const isCollapseUnfold = () => {
  262. if (isCollapse.value) {
  263. contentStyle.value = deepClone(collapseHeight.value)
  264. isCollapse.value = false
  265. } else {
  266. contentStyle.value = deepClone(unfoldHeight.value)
  267. isCollapse.value = true
  268. }
  269. }
  270. //立即填报
  271. const fillReport = () => {
  272. const {excelId, primaryKeyId, title, nodeType} = tabItem.value
  273. const {real_name} = userInfo.value
  274. uni.navigateTo({
  275. url: '/pages/ledger/editTable?node=' + encodeURIComponent(JSON.stringify({
  276. projectId: projectId.value ?? '',
  277. contractId: contractId.value ?? '',
  278. excelId: excelId ?? '',
  279. pkeyId: primaryKeyId ?? '',
  280. title: title ?? '',
  281. date: fullDate.value ?? '',
  282. nodeType: nodeType,
  283. taskName: `${fullDate.value} ${title} ${real_name}`,
  284. }))
  285. });
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. page {
  290. background: #EFEFF4;
  291. height: 100%;
  292. }
  293. </style>
  294. <style lang="scss">
  295. @import "@/style/ledger/index.scss";
  296. </style>