dataTable.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <hc-sys navBarUi='data-table-nav-bar'>
  3. <template #navBar>
  4. <hc-nav-back-bar ui='data-table-nav-bar' :title="treeNode.title"/>
  5. </template>
  6. <uni-collapse class="mb-4" v-model="appUserValue" v-if="appUserList.length">
  7. <uni-collapse-item title="填过数据的用户" >
  8. <view class="hc-table-avatar-content">
  9. <hc-img v-for="item in appUserList" class="avatar-img" :src="item.avatar??avatarPng" :width="35" :height="35"/>
  10. </view>
  11. </uni-collapse-item>
  12. </uni-collapse>
  13. <!--表单列表-->
  14. <template v-if="listItemData.length > 0">
  15. <uni-card v-for="(item, index) in listItemData" padding="0">
  16. <template v-slot:title>
  17. <view class="card-slot-title">{{item.nodeName}}</view>
  18. </template>
  19. <view slot="actions" class="card-actions">
  20. <template v-if="item.isBussShow !== 2">
  21. <view class="card-actions-item border" style="color: #EE5B20" @click="toEditTable(item, index)">
  22. <text class="i-ri-edit-2-fill icon"/>
  23. <text class="card-actions-item-text">填写</text>
  24. </view>
  25. </template>
  26. <template v-if="(item.isCopeTab === 2 || item.isCopeTab === 3) && item.isBussShow !== 2">
  27. <view class="card-actions-item" style="color: #f56c6c" @click="toDelClick(item)">
  28. <text class="i-ri-delete-bin-2-fill icon"/>
  29. <text class="card-actions-item-text">删除</text>
  30. </view>
  31. </template>
  32. <template v-if="item.isLinkTable !== 1">
  33. <view class="card-actions-item" style="color: #4095e5" @click="toCopyClick(item)">
  34. <text class="i-ri-file-copy-2-fill icon"/>
  35. <text class="card-actions-item-text">复制</text>
  36. </view>
  37. </template>
  38. <template v-if="item.isBussShow === 1">
  39. <view class="card-actions-item" style="color: #999999" @click="toShowHideClick(item)">
  40. <text class="i-ri-eye-off-fill icon"/>
  41. <text class="card-actions-item-text">隐藏</text>
  42. </view>
  43. </template>
  44. <template v-if="item.isBussShow !== 1">
  45. <view class="card-actions-item" style="color: #544e80" @click="toShowHideClick(item)">
  46. <text class="i-ri-eye-fill icon"/>
  47. <text class="card-actions-item-text">显示</text>
  48. </view>
  49. </template>
  50. </view>
  51. </uni-card>
  52. </template>
  53. <view v-else class="uni-pt-16" style="text-align: center;">暂无表单</view>
  54. <!--底部操作栏-->
  55. <HcTabbarBlock :height="77"/>
  56. <hc-tabbars>
  57. <view class="hc-data-table-tabbar">
  58. <view class="item"
  59. :style="nodeStatus !== '3' && nodeStatus !== '1' ? 'color: #E99D43;' : 'color: #999999;'"
  60. @click="toReportPage"
  61. >
  62. <view class="item-icon">
  63. <text class="i-ri-send-plane-fill"/>
  64. </view>
  65. <view class="item-name">上报</view>
  66. </view>
  67. <view class="item" :style="nodeStatus === '1' ? 'color: #999999;' : ''" @click="bussPdfsClick">
  68. <view class="item-icon">
  69. <text class="i-ri-eye-fill"/>
  70. </view>
  71. <view class="item-name">预览</view>
  72. </view>
  73. <view class="item" :style="nodeStatus !== '3' ? 'color: #999999;' : ''" @click="abolishOneClick">
  74. <view class="item-icon">
  75. <text class="i-ri-delete-bin-5-line"/>
  76. </view>
  77. <view class="item-name">废除</view>
  78. </view>
  79. </view>
  80. </hc-tabbars>
  81. </hc-sys>
  82. </template>
  83. <script setup>
  84. import {ref} from "vue";
  85. import {onLoad, onShow} from '@dcloudio/uni-app'
  86. import {useAppStore} from "@/store";
  87. import wbsApi from '~api/data-fill/wbs';
  88. import {getArrValue} from "js-fast-way";
  89. import avatarPng from "@/static/image/avatar.png";
  90. import {errorToast, successToast, toPdfPreview} from "@/utils/tools";
  91. import { eVisaTaskCheck } from '~api/other/index'
  92. import api from '~api/api';
  93. const store = useAppStore()
  94. const isNodes = ref(false)
  95. //初始变量
  96. const contractInfo = ref(store.contractInfo);
  97. const projectId = ref(store.projectId);
  98. const contractId = ref(store.contractId);
  99. const treeNode = ref({})
  100. const appUserValue = ref(['0'])
  101. onLoad((option) => {
  102. if (option.node) {
  103. treeNode.value = JSON.parse(decodeURIComponent(option.node));
  104. getTableDataAll();
  105. }
  106. })
  107. onShow(() => {
  108. if (isNodes.value) {
  109. getTableDataAll()
  110. }
  111. })
  112. //获取相关数据
  113. const getTableDataAll = () => {
  114. searchNodeAllTable()
  115. queryNodeStatus()
  116. }
  117. //获取列表数据
  118. const listItemData = ref([])
  119. const appUserList = ref([])
  120. const searchNodeAllTable = async () => {
  121. uni.showLoading({title: '加载中...', mask: true});
  122. const info = treeNode.value
  123. const { data } = await wbsApi.searchNodeAllTable({
  124. projectId: projectId.value,
  125. contractId: contractId.value,
  126. primaryKeyId: info['primaryKeyId'],
  127. type: contractInfo.value?.contractType ?? '',
  128. })
  129. const res = getArrValue(data)
  130. listItemData.value = res
  131. //获取用户列表
  132. const userMap = new Map();
  133. res.forEach((item) => {
  134. const userList = getArrValue(item?.appUserList)
  135. userList.forEach(user => {
  136. userMap.set(user.id,user);
  137. })
  138. })
  139. appUserList.value = [...userMap.values()]
  140. isNodes.value = true
  141. uni.hideLoading();
  142. }
  143. //当前节点状态, 1 未填报,2待上报,3已上报
  144. const nodeStatus = ref('1');
  145. const queryNodeStatus = async () => {
  146. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  147. let url = `blade-business/informationWriteQuery/${type === 1?'queryNodeStatus': 'queryNodeStatus-jl'}`;
  148. //查询节点状态
  149. const { error, code, data } = await api.post({
  150. url: url,
  151. params: {
  152. primaryKeyId: info['primaryKeyId'] ?? '',
  153. classify: type,
  154. }
  155. })
  156. if (!error && code === 200) {
  157. nodeStatus.value = data ?? '1'
  158. } else {
  159. nodeStatus.value = '1'
  160. }
  161. }
  162. //填写表单
  163. const toEditTable = (item) => {
  164. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  165. if(!pkeyId){
  166. errorToast('pkeyId为空');
  167. return
  168. } else if (item.isBussShow === 2) {
  169. errorToast('此表单当前状态不可填写');
  170. return
  171. }
  172. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  173. uni.navigateTo({
  174. url: '/pages/data-fill/editTable?node=' + encodeURIComponent(JSON.stringify({
  175. projectId: projectId.value,
  176. contractId: contractId.value,
  177. status: nodeStatus.value,
  178. treeId: info['primaryKeyId'],
  179. pkeyId: pkeyId,
  180. classify: type,
  181. title: item.nodeName,
  182. isBussShow: item.isBussShow,
  183. isTabPdf: item.isTabPdf,
  184. pdfUrl: item.pdfUrl,
  185. tabFileType: item.tabFileType,
  186. }))
  187. });
  188. }
  189. //删除本表
  190. const toDelClick = async (item) => {
  191. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  192. const type = Number(contractInfo.value?.contractType ?? '')
  193. if(!pkeyId){
  194. errorToast('pkeyId为空');
  195. return
  196. } else if(nodeStatus.value === '3'){
  197. errorToast('已上报的资料,不允许删除');
  198. return
  199. }
  200. uni.showLoading({title: '删除中...', mask: true});
  201. const { error, code, msg } = await wbsApi.removeBussTabInfo({
  202. pkeyid: pkeyId,
  203. classify: type,
  204. })
  205. uni.hideLoading();
  206. if (!error && code === 200) {
  207. getTableDataAll();
  208. successToast('删除成功');
  209. } else {
  210. errorToast('删除失败:' + msg);
  211. }
  212. }
  213. //复制本表
  214. const toCopyClick = async (item) => {
  215. const pkeyId = item.pkeyId ? item.pkeyId + '': ''
  216. if(nodeStatus.value === '3'){
  217. errorToast('已上报的资料,不允许复制');
  218. return
  219. } else if(!pkeyId){
  220. errorToast('pkeyId为空');
  221. return
  222. }
  223. uni.showLoading({title: '复制中...', mask: true});
  224. const { error, code, msg } = await wbsApi.copeBussTab({
  225. pkeyId: pkeyId,
  226. })
  227. uni.hideLoading();
  228. if (!error && code === 200) {
  229. getTableDataAll();
  230. successToast('复制成功');
  231. } else {
  232. errorToast('复制失败:' + msg);
  233. }
  234. }
  235. //隐藏本表
  236. const toShowHideClick = async ({ pkeyId, isBussShow }) => {
  237. const pkey_id = pkeyId ? pkeyId + '': ''
  238. if(!pkey_id){
  239. errorToast('pkeyId为空');
  240. return
  241. } else if(nodeStatus.value === '3'){
  242. errorToast('已上报的资料,不允许隐藏或显示');
  243. return
  244. }
  245. uni.showLoading({title: '操作请求中...', mask: true});
  246. const bussShow = isBussShow === 2 ? 1 : 2 //状态(1显示 2隐藏)
  247. const {contractIdRelation, primaryKeyId } = treeNode.value;
  248. const type = Number(contractInfo.value?.contractType ?? '')
  249. const { error, code, msg } = await wbsApi.showBussTab({
  250. pkeyId: pkey_id,
  251. status: bussShow,
  252. classify: type,
  253. nodeId: primaryKeyId,
  254. })
  255. uni.hideLoading();
  256. if (!error && code === 200) {
  257. getTableDataAll();
  258. successToast('操作成功');
  259. } else {
  260. errorToast('操作失败:' + msg);
  261. }
  262. }
  263. //上报
  264. const toReportPage = async () => {
  265. if(nodeStatus.value === '3'){
  266. errorToast('已上报,无法重复上报');
  267. return
  268. } else if(nodeStatus.value === '1'){
  269. errorToast('请填写保存后再进行上报');
  270. return
  271. }
  272. const rows = listItemData.value
  273. if (rows.length <= 0) {
  274. errorToast('暂无相关数据');
  275. return
  276. }
  277. uni.showLoading({title: '准备相关的数据中...', mask: true});
  278. const {contractIdRelation, primaryKeyId } = treeNode.value;
  279. const type = Number(contractInfo.value?.contractType ?? '')
  280. const { error, code, msg, data } = await eVisaTaskCheck({
  281. projectId: projectId.value,
  282. contractId: type === 2 ? contractIdRelation : contractId.value,
  283. })
  284. //处理数据
  285. if (!error && code === 200 && data === true) {
  286. let newArr = []
  287. for (let i = 0; i < rows.length; i++) {
  288. newArr.push(rows[i]['isTypePrivatePid'])
  289. }
  290. //请求文件题名
  291. const { data } = await wbsApi.queryDocumentTitle({
  292. primaryKeyId: primaryKeyId,
  293. classify: type,
  294. })
  295. uni.hideLoading();
  296. //路由跳转
  297. uni.navigateTo({
  298. url: '/pages/report/report',
  299. events:{
  300. finish: function(data) {
  301. getTableDataAll();
  302. }
  303. },
  304. success: function(res){
  305. res.eventChannel.emit('reportProps', {
  306. type: "wbs",
  307. ids: primaryKeyId,
  308. taskName: data ?? '',
  309. typeData: newArr,
  310. projectId: projectId.value,
  311. contractId: type === 2 ? contractIdRelation : contractId.value,
  312. url: 'informationWriteQuery/taskOne',
  313. addition: {
  314. classify: type,
  315. contractIdRelation: contractIdRelation,
  316. },
  317. })
  318. }
  319. });
  320. } else {
  321. uni.hideLoading();
  322. errorToast(msg);
  323. }
  324. }
  325. //预览
  326. const bussPdfsClick = async () => {
  327. if(nodeStatus.value === '1'){
  328. errorToast('请先填报后再进行预览');
  329. return
  330. }
  331. uni.showLoading({title: '获取数据中...', mask: true});
  332. const {contractIdRelation, primaryKeyId } = treeNode.value;
  333. const type = Number(contractInfo.value?.contractType ?? '')
  334. const { error, code, msg, data } = await wbsApi.getBussPdfs({
  335. nodeId: primaryKeyId ?? '',
  336. classify: type,
  337. projectId: projectId.value,
  338. contractId: type === 2 ? contractIdRelation : contractId.value,
  339. })
  340. uni.hideLoading();
  341. if (!error && code === 200) {
  342. toPdfPreview(data)
  343. } else {
  344. errorToast('获取PDF失败:' + msg);
  345. }
  346. }
  347. //废除 = 客户端中的撤回上报流程
  348. const abolishOneClick = () => {
  349. if(nodeStatus.value !== '3'){
  350. errorToast('只有上报后才能废除上报');
  351. return
  352. }
  353. uni.showModal({
  354. title: '废除上报',
  355. content: '请谨慎考虑后,是否确定废除',
  356. success: (res) => {
  357. if (res.confirm) {
  358. abolishOneSave()
  359. }
  360. }
  361. });
  362. }
  363. //撤回上报的请求
  364. const abolishOneSave = async () => {
  365. uni.showLoading({title: '操作请求中...', mask: true});
  366. const info = treeNode.value, type = Number(contractInfo.value?.contractType ?? '')
  367. const { error, code, msg } = await wbsApi.abolishOne({
  368. primaryKeyId: info['primaryKeyId'],
  369. classify: type,
  370. })
  371. uni.hideLoading();
  372. if (!error && code === 200) {
  373. getTableDataAll();
  374. successToast('废除成功');
  375. } else {
  376. errorToast('废除失败:' + msg);
  377. }
  378. }
  379. </script>
  380. <style lang="scss" scoped>
  381. page {
  382. background: #FAFBFE;
  383. }
  384. @import "@/style/data-fill/data-table.scss";
  385. </style>
  386. <style lang="scss">
  387. page {
  388. height: auto;
  389. }
  390. </style>