index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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, onShow} 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 isNodes = ref(false)
  56. const instance = getCurrentInstance().proxy
  57. const contractInfo = ref(store.contractInfo);
  58. const userInfo = ref(store.userInfo);
  59. const projectId = ref(store.projectId);
  60. const contractId = ref(store.contractId);
  61. //页面启动完成
  62. onLoad(() => {
  63. fullDate.value = dayjs().format('YYYY-MM-DD')
  64. fullYear.value = dayjs().format('YYYY')
  65. getDataApi()
  66. })
  67. onReady(() => {
  68. setContentStyle()
  69. })
  70. onShow(() => {
  71. if (isNodes.value) {
  72. getDataApi()
  73. }
  74. })
  75. //设置样式
  76. const bottomStyle = ref({}) // 距离底部
  77. const setContentStyle = async () => {
  78. const {height: appHeight } = await querySelect(instance, 'app-sys')
  79. const {height: navHeight } = await querySelect(instance, 'nav-bar')
  80. const {height: dateHeight } = await querySelect(instance, 'date-bar')
  81. const {height: tabHeight } = await querySelect(instance, 'tab-bar')
  82. bottomStyle.value = { bottom: tabHeight + 'px' }
  83. // 展开高度
  84. const unfold_height = appHeight - tabHeight
  85. // #ifdef H5
  86. unfoldHeight.value = { height: (unfold_height - (navHeight * 4)) + 'px' }
  87. // #endif
  88. // #ifdef APP-PLUS
  89. unfoldHeight.value = { height: (unfold_height - (navHeight * 7)) + 'px' }
  90. // #endif
  91. contentStyle.value = deepClone(unfoldHeight.value)
  92. //收起高度
  93. const collapse_height = appHeight - dateHeight - tabHeight
  94. // #ifdef H5
  95. collapseHeight.value = { height: (collapse_height - navHeight)+ 'px' }
  96. // #endif
  97. // #ifdef APP-PLUS
  98. collapseHeight.value = { height: (collapse_height - (navHeight * 3.5)) + 'px' }
  99. // #endif
  100. }
  101. //获取接口数据
  102. const getDataApi= async () => {
  103. await queryLogList()
  104. queryLogTimeTreeList().then()
  105. getSubmitLogDateList().then()
  106. isNodes.value = true
  107. }
  108. //获取tab数据
  109. const tabList = ref([])
  110. const tabItem = ref({})
  111. const queryLogList = async () => {
  112. const { data } = await mainApi.queryLogList({
  113. projectId: projectId.value,
  114. contractId: contractId.value,
  115. })
  116. const dataArr = getArrValue(data)
  117. if (dataArr.length > 0) {
  118. tabList.value = dataArr
  119. tabItem.value = dataArr[0]
  120. tabKey.value = dataArr[0]?.primaryKeyId
  121. } else {
  122. tabList.value = []
  123. tabItem.value = {}
  124. tabKey.value = ''
  125. }
  126. }
  127. //tab切换
  128. const tabKey = ref('')
  129. const scrollLeft = ref(0)
  130. const tabSelect = async (item, index) => {
  131. tabItem.value = item
  132. tabKey.value = item?.primaryKeyId
  133. scrollLeft.value = (index - 1) * 60
  134. uni.showLoading({title: '获取数据中...', mask: true});
  135. await queryLogTimeTreeList()
  136. await getSubmitLogDateList()
  137. uni.hideLoading()
  138. }
  139. //日历变量
  140. const calendarSelected = ref([])
  141. const getSubmitLogDateList = async () => {
  142. if (fullYear.value && tabKey.value) {
  143. const { data } = await mainApi.getSubmitLogDateList({
  144. projectId: projectId.value,
  145. contractId: contractId.value,
  146. primaryKeyId: tabKey.value,
  147. year: fullYear.value,
  148. })
  149. //处理数据
  150. let newArr = [], res = getArrValue(data)
  151. res.forEach((item)=>{
  152. newArr.push({ date: item })
  153. })
  154. calendarSelected.value = newArr
  155. } else {
  156. calendarSelected.value = []
  157. }
  158. }
  159. //切换年月
  160. const fullYear = ref('')
  161. const calendarSwitch = ({year}) => {
  162. if (year !== fullYear.value) {
  163. fullYear.value = year
  164. getSubmitLogDateList()
  165. }
  166. }
  167. //选择日期
  168. const fullDate = ref('')
  169. const calendarChange = ({fulldate, year}) => {
  170. if (fulldate !== fullDate.value) {
  171. fullDate.value = fulldate
  172. queryLogTimeTreeList()
  173. }
  174. if (year !== fullYear.value) {
  175. fullYear.value = year
  176. getSubmitLogDateList()
  177. }
  178. }
  179. //获取填报记录
  180. const timeFormData = ref([])
  181. const queryLogTimeTreeList = async () => {
  182. const { data } = await mainApi.queryLogTimeTreeList({
  183. contractId: contractId.value,
  184. nodePrimaryKeyId: tabKey.value,
  185. time: fullDate.value,
  186. })
  187. timeFormData.value = getArrValue(data)
  188. }
  189. //查看
  190. const handleTableQuery = async (item) => {
  191. if (item.pdfUrl) {
  192. toPdfPreview(item.pdfUrl).then()
  193. return false
  194. }
  195. uni.showLoading({title: '获取pdf文件中...', mask: true});
  196. const {excelId, primaryKeyId} = tabItem.value
  197. const { error, code, data } = await mainApi.getBussPdfInfo({
  198. contractId: contractId.value,
  199. pkeyId: excelId,
  200. nodePrimaryKeyId: primaryKeyId,
  201. recordTime: fullDate.value,
  202. theLogId: ""
  203. })
  204. const resData = isString(data) ? data ?? '' : ''
  205. uni.hideLoading();
  206. if (!error && code === 200 && resData) {
  207. toPdfPreview(resData).then()
  208. } else {
  209. errorToast('暂无PDF,无法预览')
  210. }
  211. }
  212. //上报
  213. const toReportPage = ({createUser, recordTime}) => {
  214. const {primaryKeyId, title} = tabItem.value, {real_name} = userInfo.value
  215. //路由跳转
  216. uni.navigateTo({
  217. url: '/pages/report/report',
  218. events:{
  219. finish: (data) => {
  220. queryLogTimeTreeList();
  221. }
  222. },
  223. success:(res) => {
  224. res.eventChannel.emit('reportProps', {
  225. type: "log",
  226. typeData: primaryKeyId,
  227. projectId: projectId.value,
  228. contractId: contractId.value,
  229. taskName: `${recordTime} ${title} ${real_name}`,
  230. url: 'contractLog/startTaskTheLog',
  231. addition: {
  232. nodePrimaryKeyId: primaryKeyId,
  233. recordTime: recordTime,
  234. userId: createUser,
  235. },
  236. })
  237. }
  238. });
  239. }
  240. //废除
  241. const handleAbolish = async (item) => {
  242. const res = await showModal({
  243. title: '废除上报',
  244. content: '请谨慎考虑后,是否确定废除',
  245. })
  246. if (!res) return
  247. uni.showLoading({title: '废除上报中...', mask: true});
  248. const {primaryKeyId} = tabItem.value
  249. const { error, code } = await mainApi.theLogOneAbolish({
  250. projectId: projectId.value,
  251. contractId: contractId.value,
  252. nodePrimaryKeyId: primaryKeyId,
  253. recordTime: item.recordTime
  254. })
  255. uni.hideLoading();
  256. if (!error && code === 200) {
  257. successToast('废除成功')
  258. queryLogTimeTreeList().then()
  259. } else {
  260. errorToast('废除失败')
  261. }
  262. }
  263. //展开收缩
  264. const collapseHeight = ref({}) // 收起高度
  265. const unfoldHeight = ref({}) // 展开高度
  266. const isCollapse = ref(true) // 是否展开
  267. const contentStyle = ref({}) // 设置高度
  268. const isCollapseUnfold = () => {
  269. if (isCollapse.value) {
  270. contentStyle.value = deepClone(collapseHeight.value)
  271. isCollapse.value = false
  272. } else {
  273. contentStyle.value = deepClone(unfoldHeight.value)
  274. isCollapse.value = true
  275. }
  276. }
  277. //立即填报
  278. const fillReport = () => {
  279. const {excelId, primaryKeyId, title, nodeType} = tabItem.value
  280. const {real_name} = userInfo.value
  281. uni.navigateTo({
  282. url: '/pages/ledger/editTable?node=' + encodeURIComponent(JSON.stringify({
  283. projectId: projectId.value ?? '',
  284. contractId: contractId.value ?? '',
  285. excelId: excelId ?? '',
  286. pkeyId: primaryKeyId ?? '',
  287. title: title ?? '',
  288. date: fullDate.value ?? '',
  289. nodeType: nodeType,
  290. taskName: `${fullDate.value} ${title} ${real_name}`,
  291. }))
  292. });
  293. }
  294. </script>
  295. <style lang="scss" scoped>
  296. page {
  297. background: #EFEFF4;
  298. height: 100%;
  299. }
  300. </style>
  301. <style lang="scss">
  302. @import "@/style/ledger/index.scss";
  303. </style>