ListItem.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. <template>
  2. <div class="data-fill-list-box">
  3. <el-collapse v-model="ActiveKey" @change="CollapseChange">
  4. <template v-for="(item,index) in listDatas" :key="item?.pkeyId">
  5. <el-collapse-item :name="`item-${index}-${item?.pkeyId}`" :disabled="item['isBussShow'] === 2" :id="`item-${index}-${item?.pkeyId}`">
  6. <template #title>
  7. <div class="hc-collapse-item-header">
  8. <div class="text-lg truncate item-title">{{item.nodeName}}</div>
  9. <div class="hc-extra-text-box">
  10. <HcTooltip keys="wbs_del_table" v-if="item['isCopeTab'] === 2">
  11. <el-button type="danger" plain :disabled="item['isBussShow'] === 2" @click.stop="delClick(item,index)">删除本表</el-button>
  12. </HcTooltip>
  13. <HcTooltip keys="wbs_copy_table">
  14. <el-button type="primary" plain :disabled="item['isBussShow'] === 2" @click.stop="copyClick(item,index)">复制本表</el-button>
  15. </HcTooltip>
  16. <HcTooltip keys="wbs_hide_table">
  17. <el-button type="primary" plain @click.stop="hideClick(item,index)">
  18. <template v-if="item['isBussShow'] === 1">隐藏本表</template>
  19. <template v-else>显示本表</template>
  20. </el-button>
  21. </HcTooltip>
  22. <HcTooltip keys="wbs_preview_table" v-if="isStatus != 3">
  23. <el-button type="info" plain disabled v-if="item['isBussShow'] === 2 || item['isTabPdf'] === 1">预览</el-button>
  24. <el-button type="primary" plain @click.stop="previewClick(item,index)" v-else>预览</el-button>
  25. </HcTooltip>
  26. <HcTooltip keys="wbs_upload_table">
  27. <el-button :type="item['tabFileType'] === 2?'success':'primary'" plain :disabled="item['isBussShow'] === 2" @click.stop="uploadClick(item,index)">
  28. <template v-if="item['tabFileType'] === 2">已上传</template>
  29. <template v-else>上传</template>
  30. </el-button>
  31. </HcTooltip>
  32. </div>
  33. </div>
  34. </template>
  35. <div class="data-fill-list-item-content">
  36. <div class="data-fill-table-form-box">
  37. <div class="hc-excel-table-form-view" :id="`table-form-${item?.pkeyId}`"/>
  38. <div class="hc-no-table-form" v-if="item?.isTableForm === false">
  39. <div class="table-form-no">
  40. <img :src="notableform" alt=""/>
  41. <div class="desc">暂无表单数据</div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="data-fill-table-tip-box">
  46. <div class="text-orange tip-title">
  47. <HcIcon name="error" fill ui="text-2xl"/>
  48. <span class="ml-1">提示</span>
  49. </div>
  50. <div class="text-gray-400 tip-item">1、灰色框代表可通过系统识别计算,公式自动引用,可通过公式计算少量数据,(表头数据及简单),也可只填写白色框数据</div>
  51. <div class="text-gray-400 tip-item">2、系统支持键盘中,shift + tab键向上一个填报框切换,tab向下一个填报框切换。暂不支持上下按键切换输入框</div>
  52. <div class="table-tip-foot">
  53. <div class="tip-left-btn">
  54. <HcTooltip keys="wbs_import_table">
  55. <div class="text-gray-400 dow-text">
  56. <HcIcon name="publish" ui="text-lg"/>
  57. <span class="ml-1">导入列表数据</span>
  58. </div>
  59. </HcTooltip>
  60. <HcTooltip keys="wbs_download_table">
  61. <div class="text-main dow-text">
  62. <HcIcon name="file_download" ui="text-lg"/>
  63. <span class="ml-1">下载导入模板</span>
  64. </div>
  65. </HcTooltip>
  66. </div>
  67. <div class="tip-right-btn">
  68. <HcTooltip keys="wbs_save_table">
  69. <el-button type="primary" hc-btn :disabled="item?.isTableForm === false" :loading="tableFormSaveLoading" @click="tableFormSaveClick(item,index)">
  70. <HcIcon name="save"/>
  71. <span>保存</span>
  72. </el-button>
  73. </HcTooltip>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </el-collapse-item>
  79. </template>
  80. </el-collapse>
  81. </div>
  82. <!--右键菜单-->
  83. <HcContextMenu ref="contextMenuRef" :datas="tableFormMenu" @item-click="handleMenuSelect"/>
  84. <!--上传文件-->
  85. <HcDialog :show="uploadModal" title="上传文件" widths="38rem" :footer="false" @close="uploadModal = false">
  86. <HcUpload :fileList="fileListData" :datas="uploadData" @change='uploadChange'/>
  87. </HcDialog>
  88. <!--插入设计值/频率-->
  89. <HcDialog :show="IDVFModal" title="插入设计值/频率" widths="600px" saveText="确认插入" @close="IDVFModal = false" @save="IDVFModalSaveClick">
  90. <el-alert title="填写完设计值和频率,系统自动计算实测值" type="warning" :closable="false"/>
  91. <el-form ref="formIDVFRef" :model="formIDVFModel" label-width="auto" size="large">
  92. <div class="form-item-div text-center mb-3">
  93. <el-radio-group size="large" v-model="formIDVFModel.type">
  94. <el-radio :label="1">公路工程</el-radio>
  95. <el-radio :label="2" class="ml-4">水利水电</el-radio>
  96. </el-radio-group>
  97. </div>
  98. <el-form-item label="设计值">
  99. <!-- onkeyup="value = value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g,'$1')" -->
  100. <el-input v-model="formIDVFModel.design" placeholder="如果设计值存在两个,则使用 '*',或者 '/' 连接,例如45*78,12/23"/>
  101. </el-form-item>
  102. <el-form-item label="频率" v-if="formIDVFModel.type === 1">
  103. <!-- onkeyup="value = value.replace(/^(0+)|[^\d]+/g,'')" -->
  104. <el-input v-model="formIDVFModel.size" placeholder="如果频率存在两个,则使用 '*',或者 '/' 连接例如2*4,5/7"/>
  105. </el-form-item>
  106. <el-form-item label="容量" v-if="formIDVFModel.type === 2">
  107. <!-- onkeyup="value = value.replace(/^(0+)|[^\d]+/g,'')" -->
  108. <el-input v-model="formIDVFModel.capacity" placeholder="如果容量存在两个,则使用 '*',或者 '/' 连接例如2*4,5/7"/>
  109. </el-form-item>
  110. <el-form-item label="合格点数">
  111. <el-input v-model="formIDVFModel.fail" placeholder="请填写合格点数(不填写则默认全部合格)" onkeyup="value = value.replace(/^(0+)|[^\d]+/g,'')"/>
  112. </el-form-item>
  113. <el-form-item label="偏差范围">
  114. <el-input v-model="formIDVFModel.dev" placeholder="请填写偏差范围" />
  115. </el-form-item>
  116. </el-form>
  117. </HcDialog>
  118. <!--插入特殊字符-->
  119. <HcDialog :show="specialModal" title="插入特殊字符" widths="600px" saveText="确认插入" @close="specialModal = false" @save="specialNodeClick">
  120. <el-form ref="specialFormRef" :model="specialFormModel" :rules="specialFormRules" label-width="0px" size="large" class="mb-6">
  121. <el-form-item prop="val" class="special-form-item">
  122. <el-input v-model="specialFormModel.val" ref="specialRef" id="specialId" placeholder="请选择特殊字符代码" clearable @blur="specialInputBlur"/>
  123. </el-form-item>
  124. </el-form>
  125. <el-row :gutter="20" style="margin: -10px;">
  126. <el-col :span="3" style="padding: 10px;" v-for="item in specialCharacters">
  127. <div class="special-box" @click="specialClick">
  128. <span class="font-EUDC" :title="`字符代码(C):${item !== 'K̅'?item.slice(2,7):'K̅'}`" v-html="item"/>
  129. </div>
  130. </el-col>
  131. </el-row>
  132. </HcDialog>
  133. <!--关联试验数据-->
  134. <HcDialog :show="CTDModal" title="关联试验数据" widths="850px" saveText="确认关联" @close="CTDModal = false" @save="CTDModal = false">
  135. 开发中...
  136. </HcDialog>
  137. <!-- 复制本表 -->
  138. <HcDialog :show="CopyModal" title="复制本表" widths="1200px" saveText="确认复制" @close="CopyModal = false" @save="CopyModal = false">
  139. <el-alert title="复跨节点复制: 把当前表格已形成的数据复制到其他工程部位的相同表格里面" type="warning" :closable="false"/>
  140. <el-alert title="本节点复制:在当前节点内复制本表及数据" type="warning" :closable="false"/>
  141. <div class="radio-group-box">
  142. <el-radio-group v-model="CopyModalType">
  143. <el-radio label="1">跨节点复制</el-radio>
  144. <el-radio label="2" class="ml-4">本节点复制</el-radio>
  145. </el-radio-group>
  146. </div>
  147. <div class="copy-node-many-box" v-if="CopyModalType=== '1'">
  148. <div class="copy-node-many-tree">
  149. <el-scrollbar>
  150. <WbsTree
  151. :projectId="projectId"
  152. :contractId="contractId"
  153. @nodeTap="wbsElTreeClick"
  154. @nodeLoading="ElTreeNodeLoading"
  155. />
  156. </el-scrollbar>
  157. </div>
  158. <div class="copy-node-many-table">
  159. <el-scrollbar v-loading="ListItemLoading" >
  160. <el-table :data="copyModalTable" border stripe>
  161. <el-table-column prop="fullName" label="表格名称"/>
  162. <el-table-column prop="action" label="操作" width="120" align="center">
  163. <template #default="{row}">
  164. <el-checkbox v-model="row.isCheck" size="large" @change="copyModalTableCheck(row)"/>
  165. </template>
  166. </el-table-column>
  167. </el-table>
  168. </el-scrollbar>
  169. </div>
  170. </div>
  171. </HcDialog>
  172. </template>
  173. <script setup>
  174. import {ref,watch,nextTick} from "vue";
  175. import {getStoreData, setStoreData} from '~src/utils/storage'
  176. import notableform from '~src/assets/view/notableform.svg';
  177. import HTableForm from "~src/plugins/HTableForm"
  178. import WbsTree from "../components/WbsTree.vue"
  179. import wbsApi from "~api/data-fill/wbs"
  180. import HcUpload from "./HcUpload.vue"
  181. import {utilsText, isType, formValidate, deepClone, getObjValue} from "vue-utils-plus"
  182. import {useAppStore} from "~src/store";
  183. //初始
  184. const props = defineProps({
  185. datas: {
  186. type: Array,
  187. default: () => ([])
  188. },
  189. classify: {
  190. type: [String,Number],
  191. default: ''
  192. },
  193. status: {
  194. type: [String,Number],
  195. default: ''
  196. },
  197. primaryKeyId: {
  198. type: [String,Number],
  199. default: ''
  200. },
  201. contractId: {
  202. type: [String,Number],
  203. default: ''
  204. },
  205. projectInfo: {
  206. type: Object,
  207. default: () => ({})
  208. },
  209. authBtnTabKey: {
  210. type: [String,Number],
  211. default: ''
  212. },
  213. })
  214. const {isString, getObjNullValue, getArrValue} = isType()
  215. const {setPosInsert, setPosRange} = utilsText()
  216. const listDatas = ref(props.datas)
  217. const classify = ref(props.classify)
  218. const isStatus = ref(props.status)
  219. const isPrimaryKeyId = ref(props.primaryKeyId)
  220. const contractId = ref(props.contractId)
  221. const projectInfo = ref(props.projectInfo)
  222. const useAppState = useAppStore()
  223. const authBtnTabKey = ref(props.authBtnTabKey)
  224. //全局变量
  225. const projectId = ref(useAppState.getProjectId);
  226. //监听
  227. watch(() => [
  228. props.datas,
  229. props.classify,
  230. props.primaryKeyId,
  231. props.contractId,
  232. props.projectInfo,
  233. ], ([datas, classifyVal, primaryKeyId, cid, pInfo]) => {
  234. listDatas.value = datas
  235. classify.value = classifyVal
  236. isPrimaryKeyId.value = primaryKeyId
  237. contractId.value = cid
  238. projectInfo.value = pInfo
  239. setFormDataNum(datas)
  240. })
  241. //监听
  242. watch(() => [
  243. props.status
  244. ], ([val]) => {
  245. //1 未填报,2待上报,3已上报
  246. isStatus.value = val
  247. })
  248. //渲染完成
  249. nextTick(() => {
  250. setFormDataNum(props.datas)
  251. })
  252. //获取表单初始数据
  253. const getFormDataInit = (item, pkeyId) => {
  254. return {
  255. projectId: item?.projectId,
  256. contractId: item?.contractId,
  257. classify: classify.value,
  258. pkeyId: pkeyId ? pkeyId + '' : '',
  259. nodeId: isPrimaryKeyId.value
  260. }
  261. }
  262. //设置表单对象的数量
  263. const formData = ref([])
  264. const setFormDataNum = (datas) => {
  265. ActiveKey.value = []
  266. let newArr = [];
  267. for (let i = 0; i < datas.length; i++) {
  268. newArr.push({
  269. ...getFormDataInit(datas[i], datas[i].pkeyId),
  270. isCollapseLoad: false,
  271. })
  272. }
  273. formData.value = newArr
  274. setTableFormMenu(projectInfo.value)
  275. }
  276. //展开事件
  277. const ActiveKey = ref([])
  278. const formKeyIds = ref('')
  279. const CollapseChange = async (name) => {
  280. ActiveKey.value = name
  281. const names = name[0] ? name[0].split('-') : []
  282. if (names.length > 0) {
  283. getOffsetTop(name);
  284. const index = names[1]
  285. const item = listDatas.value[index]
  286. formKeyIds.value = item.pkeyId ? item.pkeyId + '' : ''
  287. if (!item.isTableFormRender) {
  288. //获取已填写的数据
  289. await getBussDataInfo(item,item.pkeyId, index)
  290. //渲染表单
  291. await getExcelHtml(item,index)
  292. }
  293. } else {
  294. getOffsetTop()
  295. formKeyIds.value = ''
  296. }
  297. }
  298. //获取模板标签数据
  299. const formRegExpJson = ref({})
  300. const getExcelHtml = async (item,index) => {
  301. const pkeyIds = item.pkeyId ? item.pkeyId + '' : ''
  302. if (pkeyIds) {
  303. const {error, code, data} = await wbsApi.getExcelHtml({pkeyId: pkeyIds}, false)
  304. const resData = isString(data) ? data || '' : ''
  305. if (!error && code === 200 && resData) {
  306. item.isTableForm = true
  307. //渲染表单
  308. HTableForm.createForm({
  309. template: resData,
  310. tableForm: formData.value[index],
  311. appId: `#table-form-${pkeyIds}`,
  312. onRight: (event, KeyName) => {
  313. onRightClick(event, KeyName, index)
  314. },
  315. //表单正则效验
  316. onBlur: (event, key, reg, val, msg, leng) => {
  317. setTableFormBlurReg(pkeyIds, event, key, reg, val, msg, item, index, leng)
  318. }
  319. })
  320. item.isTableFormRender = true
  321. item.isRenderTableForm = true
  322. } else {
  323. item.isTableForm = false
  324. item.isRenderTableForm = true
  325. window?.$message?.warning('暂无表单')
  326. }
  327. } else {
  328. item.isTableForm = false
  329. item.isRenderTableForm = false
  330. window?.$message?.warning('pkeyId为空')
  331. }
  332. }
  333. //正则效验
  334. const setTableFormBlurReg = (pkeyId, event, key, reg, val, msg, item, index, leng) => {
  335. const dom = document.getElementById(key)?.parentElement ?? ''
  336. if (dom) {
  337. if (val && reg) {
  338. let regx = new RegExp(reg);
  339. let state = regx.test(val);
  340. if (state) {
  341. delete formRegExpJson.value[pkeyId]
  342. dom.style = ''
  343. } else {
  344. formRegExpJson.value[pkeyId] = {key, reg, val, msg, state, nodeName: item.nodeName, itemId: `item-${index}-${item?.pkeyId}`}
  345. dom.style = '--el-input-border-color: #fe0000; box-shadow: 0 0 0 2px #fe0000 inset;'
  346. window?.$message?.warning(msg)
  347. }
  348. } else {
  349. delete formRegExpJson.value[pkeyId]
  350. dom.style = ''
  351. }
  352. /*let efficacyRegState = true, efficacyLengState = true;
  353. //正则效验
  354. if (val && reg) {
  355. let regx = new RegExp(reg);
  356. let state = regx.test(val);
  357. console.log('reg:', reg)
  358. console.log('val:', val)
  359. console.log('state:', state)
  360. if (!state) {
  361. efficacyRegState = true
  362. } else {
  363. efficacyRegState = false
  364. window?.$message?.warning(msg)
  365. }
  366. } else {
  367. efficacyRegState = true
  368. }
  369. //校验字符长度
  370. if (val && leng) {
  371. const num = val.toString().length;
  372. if (num > leng) {
  373. efficacyLengState = false
  374. window?.$message?.warning('长度不能超过' + leng)
  375. } else {
  376. efficacyLengState = true
  377. }
  378. } else {
  379. efficacyLengState = true
  380. }
  381. //处理效验结果
  382. if (efficacyRegState && efficacyLengState) {
  383. delete formRegExpJson.value[pkeyId]
  384. dom.style = ''
  385. } else {
  386. formRegExpJson.value[pkeyId] = {key, reg, val, msg, leng, state: efficacyRegState, lengState: efficacyLengState, nodeName: item.nodeName, itemId: `item-${index}-${item?.pkeyId}`}
  387. dom.style = '--el-input-border-color: #fe0000; box-shadow: 0 0 0 2px #fe0000 inset;'
  388. }*/
  389. }
  390. }
  391. //获取已填写的数据
  392. const getBussDataInfo = async (item, pkeyId, index) => {
  393. const pkeyIds = pkeyId ? pkeyId + '' : ''
  394. if (pkeyIds) {
  395. const {error, code, data} = await wbsApi.getBussDataInfo({
  396. pkeyId: pkeyIds
  397. }, false)
  398. const resData = getObjNullValue(data)
  399. if (!error && code === 200 && resData) {
  400. HTableForm.setPickerKey(resData)
  401. const InitObj = getFormDataInit(item, pkeyId) //有数据,关联数据
  402. formData.value[index] = {...resData, ...InitObj, isCollapseLoad: true}
  403. } else {
  404. formData.value[index] = {...getFormDataInit(item, pkeyId), isCollapseLoad: true}
  405. }
  406. } else {
  407. window?.$message?.warning('pkeyId为空')
  408. }
  409. }
  410. //单个保存
  411. const tableFormSaveLoading = ref(false)
  412. const tableFormSaveClick = async (item,index) => {
  413. if (isStatus.value !== '3') {
  414. const res = await saveExcelBussData(item,index)
  415. if (res) {
  416. await getBussPdfInfo(item)
  417. renewData()
  418. }
  419. } else {
  420. window?.$message?.warning('已上报的资料,不允许保存。')
  421. }
  422. }
  423. //保存表单数据
  424. const saveExcelBussData = async (item, index, showTip = true) => {
  425. const isRegExp = !!getObjNullValue(formRegExpJson.value)
  426. if (!isRegExp) {
  427. tableFormSaveLoading.value = true
  428. const InitObj = getFormDataInit(item, item.pkeyId)
  429. const {error, code} = await wbsApi.saveExcelBussData({
  430. ...formData.value[index],
  431. ...InitObj
  432. })
  433. //处理数据
  434. tableFormSaveLoading.value = false
  435. if (!error && code === 200) {
  436. if(showTip) window?.$message?.success('保存成功')
  437. return true
  438. } else {
  439. return false
  440. }
  441. } else {
  442. window?.$message?.warning('请先修改完红色输入框的数据')
  443. return false
  444. }
  445. }
  446. //预览PDF
  447. const getBussPdfInfo = async (item, showTip = true) => {
  448. const pkeyIds = item.pkeyId ? item.pkeyId + '' : ''
  449. if (pkeyIds) {
  450. const {error, code, data} = await wbsApi.getBussPdfInfo({
  451. pkeyId: pkeyIds
  452. },false)
  453. if (!error && code === 200) {
  454. if (data) {
  455. window.open(data, '_blank')
  456. } else if(showTip) {
  457. window?.$message?.warning('PDF错误')
  458. }
  459. } else {
  460. if(showTip) {
  461. window?.$message?.warning(data.msg || '获取PDF失败')
  462. }
  463. }
  464. } else {
  465. window?.$message?.warning('pkeyId为空')
  466. }
  467. }
  468. //删除本表
  469. const delClick = async (item) => {
  470. const pkeyIds = item.pkeyId ? item.pkeyId + '' : ''
  471. if (pkeyIds) {
  472. if (isStatus.value !== '3') {
  473. const {error, code} = await wbsApi.removeBussTabInfo({
  474. pkeyid: pkeyIds,
  475. classify: classify.value,
  476. })
  477. if (!error && code === 200) {
  478. window?.$message?.success('操作成功')
  479. renewData()
  480. }
  481. } else {
  482. window?.$message?.warning('已上报的资料,不允许删除')
  483. }
  484. } else {
  485. window?.$message?.warning('pkeyId为空')
  486. }
  487. }
  488. //复制本表弹窗
  489. const CopyModal = ref(false);
  490. const CopyModalType=ref('1');
  491. const treeLoading = ref(false);
  492. const copyModalTable=ref([])
  493. //树相关变量
  494. // const primaryKeyId = ref('')
  495. const nodeItemInfo = ref({})
  496. const nodeDataInfo = ref({})
  497. //树加载完成
  498. const ElTreeNodeLoading = () => {
  499. treeLoading.value = false
  500. }
  501. //获取数据列表
  502. const ListItemLoading = ref(false);
  503. const checked1=ref(true)
  504. const searchNodeAllTable = async () => {
  505. copyModalTable.value = []
  506. const info = nodeDataInfo.value;
  507. ListItemLoading.value = true
  508. const {error, code, data} = await wbsApi.searchNodeAllTable({
  509. projectId: projectId.value,
  510. contractId: contractId.value,
  511. primaryKeyId: info['primaryKeyId'],
  512. type: authBtnTabKey.value
  513. })
  514. //处理数据
  515. ListItemLoading.value = false
  516. if (!error && code === 200) {
  517. copyModalTable.value = getArrValue(data);
  518. copyModalTable.value.forEach((item)=>{
  519. item.isCheck=false
  520. })
  521. } else {
  522. copyModalTable.value = []
  523. }
  524. }
  525. const getTableDataAll = () => {
  526. searchNodeAllTable()
  527. }
  528. //树被点击
  529. const wbsElTreeClick = ({node, data, keys}) => {
  530. nodeItemInfo.value = node
  531. nodeDataInfo.value = data
  532. getTableDataAll();
  533. }
  534. //复制本表
  535. const copyClick = async (item,index) => {
  536. // CopyModal.value=true;
  537. // const copyModalTable=ref([])
  538. if (item.pkeyId) {
  539. if (isStatus.value !== '3') {
  540. if (!item.isRenderTableForm) {
  541. await copeBussTab(item.pkeyId + '')
  542. } else if (!item.isTableForm) {
  543. window?.$message?.warning('暂无表单数据')
  544. } else if (item.isRenderTableForm) {
  545. const res = await saveExcelBussData(item,index,false)
  546. if (res) {
  547. await copeBussTab(item.pkeyId + '')
  548. } else {
  549. window?.$message?.warning('复制本表操作失败')
  550. }
  551. } else {
  552. window?.$message?.warning(`数据异常了, isRenderTableForm: ${item.isRenderTableForm}, isTableForm: ${item.isTableForm}, pkeyIds:${item.pkeyId}`)
  553. }
  554. } else {
  555. window?.$message?.warning('已上报的资料,不允许复制')
  556. }
  557. } else {
  558. window?.$message?.warning('pkeyId为空')
  559. }
  560. }
  561. //勾选复制本表
  562. const copyModalTableCheck = async (item) => {
  563. console.log('复制本表',item);
  564. }
  565. const copeBussTab = async (pkeyIds) => {
  566. const {error, code} = await wbsApi.copeBussTab({
  567. pkeyId: pkeyIds
  568. })
  569. if (!error && code === 200) {
  570. window?.$message?.success('操作成功')
  571. renewData()
  572. }
  573. }
  574. //隐藏本表
  575. const hideClick = async (item) => {
  576. const pkeyIds = item.pkeyId ? item.pkeyId + '' : ''
  577. if (pkeyIds) {
  578. if (isStatus.value !== '3') {
  579. const isBussShow = item['isBussShow'] === 2 ? 1 : 2 //状态(1显示 2隐藏)
  580. const {error, code} = await wbsApi.showBussTab({
  581. pkeyId: pkeyIds,
  582. status: isBussShow
  583. })
  584. if (!error && code === 200) {
  585. window?.$message?.success('操作成功')
  586. renewData()
  587. }
  588. } else {
  589. window?.$message?.warning('已上报的资料,不允许隐藏')
  590. }
  591. } else {
  592. window?.$message?.warning('pkeyId为空')
  593. }
  594. }
  595. //预览
  596. const previewClick = async (item,index) => {
  597. await getBussPdfInfo(item)
  598. }
  599. //上传变量
  600. const uploadModal = ref(false)
  601. const fileListData = ref([]);
  602. const uploadData = ref({})
  603. //上传被点击
  604. const uploadClick = (item,index) => {
  605. const pkeyIds = item.pkeyId ? item.pkeyId + '' : ''
  606. const keyName = `item-${index}-${pkeyIds}`
  607. if (pkeyIds) {
  608. if (isStatus.value !== '3' && item.isTableForm) {
  609. uploadModal.value = true
  610. uploadData.value = getFormDataInit(item,pkeyIds)
  611. //获取文件列表
  612. getBussFileList(pkeyIds)
  613. } else if (!item.isRenderTableForm) {
  614. CollapseChange(keyName)
  615. window?.$message?.warning('请再次点击上传')
  616. } else if (!item.isTableForm) {
  617. window?.$message?.warning('暂无表单数据')
  618. } else {
  619. window?.$message?.warning('已上报的资料,不允许上传')
  620. }
  621. } else {
  622. window?.$message?.warning('pkeyId为空')
  623. }
  624. }
  625. //获取文件列表
  626. const getBussFileList = async (pkeyId) => {
  627. const {error, code, data} = await wbsApi.getBussFileList({
  628. pkeyid: pkeyId
  629. })
  630. if (!error && code === 200) {
  631. fileListData.value = getArrValue(data)
  632. } else {
  633. fileListData.value = []
  634. }
  635. }
  636. //上传文件
  637. const uploadChange = async ({type}) => {
  638. if(type === 'success') {
  639. uploadModal.value = false
  640. renewData()
  641. } else if (type === 'del') {
  642. renewData()
  643. }
  644. }
  645. //相关变量
  646. const tableFormItemNode = ref({})
  647. //菜单数据
  648. const tableFormMenu = ref([])
  649. //设置菜单权限数据
  650. const setTableFormMenu = (info) => {
  651. const infos = getObjValue(info)
  652. const isOpen = infos['isOpenRandomNumber'] ?? 0
  653. let newArr = []
  654. if (isOpen === 1) {
  655. newArr.push({label: '插入设计值/频率', key: "IDVF"})
  656. }
  657. //newArr.push({label: '插入设计值/频率', key: "IDVF"})
  658. newArr.push({label: '插入特殊字符', key: "special"})
  659. newArr.push({label: '关联试验数据', key: "CTD"})
  660. tableFormMenu.value = newArr
  661. }
  662. //鼠标右键事件
  663. const contextMenuRef = ref(null)
  664. const onRightClick = (event, KeyName, index) => {
  665. //取光标位置
  666. const specialDom = document.getElementById(KeyName + "")
  667. const startPos = specialDom?.selectionStart || 0
  668. const endPos = specialDom?.selectionEnd || 0
  669. //存储临时信息
  670. tableFormItemNode.value = {KeyName, index, startPos, endPos, pkeyId: formKeyIds.value}
  671. contextMenuRef.value?.showMenu(event) //展开菜单
  672. }
  673. //鼠标右键菜单被点击
  674. const handleMenuSelect = ({key}) => {
  675. if (key === 'IDVF') {
  676. IDVFModal.value = true
  677. } else if (key === 'special') {
  678. specialModalShow()
  679. } else if (key === 'CTD') {
  680. CTDModal.value = true
  681. }
  682. }
  683. //插入设计值
  684. const IDVFModal = ref(false)
  685. const formIDVFRef = ref(null)
  686. const formIDVFModel = ref({type: 1, design: '', size: '', dev: '', key: '', capacity: '', fail: '', pkId: ''})
  687. //插入特殊字符
  688. const specialModal = ref(false)
  689. const specialCharacters = ref([
  690. '&#57344;', "&#57345;", "&#57346;", "&#57347;", '&#8804;', '&#8805;', '&#8451;',
  691. '&#9312;', '&#9313;', '&#9314;', '&#9315;', '&#9316;', '&#9317;', '&#9318;', '&#9319;', '&#9320;', '&#9321;', '&#9322;', '&#9323;',
  692. '&#9324;', '&#9325;', '&#9326;', '&#9327;', '&#9328;', '&#9329;', '&#9330;', '&#9331;',
  693. "&#8544;", "&#8545;", "&#8546;", "&#8547;", "&#8548;", "&#8549;", "&#8550;", "&#8551;", "&#8552;", "&#8553;", "&#8554;", "&#8555;","K̅"
  694. ])
  695. //输入框验证
  696. const specialFormRef = ref(null)
  697. const specialFormModel = ref({val: ''})
  698. const specialFormRules = {
  699. val: {
  700. required: true,
  701. trigger: "blur",
  702. message: "请选择特殊字符代码"
  703. }
  704. }
  705. //显示插入特殊字符
  706. const specialRef = ref(null)
  707. const specialModalShow = () => {
  708. specialFormModel.value.val = ''
  709. specialModal.value = true
  710. nextTick(() => {
  711. specialRef.value?.focus();
  712. })
  713. }
  714. //失去焦点
  715. const specialPos = ref({start: 0, end: 0})
  716. const specialInputBlur = (e) => {
  717. specialPos.value = {
  718. start: e?.target?.selectionStart || 0,
  719. end: e?.target?.selectionEnd || 0
  720. }
  721. }
  722. //点击符号
  723. const specialClick = (event) => {
  724. const text = event?.target?.innerText ?? ''
  725. const start = specialPos.value.start
  726. const end = specialPos.value.end
  727. const form = specialFormModel.value.val
  728. specialFormModel.value.val = setPosInsert(start, end, form, text)
  729. specialRef.value?.focus();
  730. let posVal = start + text.length;
  731. nextTick(() => {
  732. setPosRange('specialId', posVal)
  733. })
  734. }
  735. //确认插入
  736. const specialNodeClick = async () => {
  737. const res = await formValidate(specialFormRef.value)
  738. if (res) {
  739. const item = tableFormItemNode.value
  740. const form = formData.value[item.index]
  741. const val = specialFormModel.value.val ?? ''
  742. formData.value[item.index][item.KeyName] = setPosInsert(item.startPos, item.endPos, form[item.KeyName], val)
  743. specialModal.value = false
  744. specialRef.value?.focus();
  745. let posVal = item.startPos + val.length;
  746. nextTick(() => {
  747. setPosRange(item.KeyName, posVal)
  748. })
  749. }
  750. }
  751. //关联试验数据
  752. const CTDModal = ref(false)
  753. //设计值频率计算
  754. const IDVFModalSaveClick = async () => {
  755. const {pkeyId, KeyName, index} = tableFormItemNode.value
  756. if (pkeyId) {
  757. const { design, size } = formIDVFModel.value
  758. const { error, code, data } = await wbsApi.queryFormulaRange({
  759. ...formIDVFModel.value,
  760. // dev: (!design && !size) ? '±5': '',
  761. key: KeyName,
  762. pkId: pkeyId,
  763. })
  764. //处理数据
  765. const res = getObjNullValue(data)
  766. if (!error && code === 200 && res) {
  767. Object.keys(data).forEach(key => {
  768. formData.value[index][key] = data[key]
  769. })
  770. IDVFModal.value = false
  771. }
  772. } else {
  773. window?.$message?.warning('pkeyId为空')
  774. }
  775. }
  776. //事件
  777. const emit = defineEmits(['renew','offsetTop'])
  778. //被点击
  779. const getOffsetTop = (key = '') => {
  780. if (key) {
  781. const dom = document.getElementById(key[key.length-1])
  782. console.log(dom.offsetTop,'dom.offsetTop');
  783. if(dom.offsetTop>=583&&ActiveKey.value.length>1){
  784. emit('offsetTop', dom.offsetTop-583)
  785. }else{
  786. emit('offsetTop', dom.offsetTop)
  787. }
  788. } else {
  789. emit('offsetTop', 0)
  790. }
  791. ActiveKey.value = ActiveKey.value[ActiveKey.value.length-1]
  792. }
  793. //通知数据更新
  794. const renewData = () => {
  795. emit('renew')
  796. ActiveKey.value = []
  797. }
  798. //获取表单数据
  799. const getFormData = () => {
  800. const formArr = formData.value;
  801. return formArr.filter((item) => {
  802. return (item.pkeyId??'') !== '' && item.isCollapseLoad;
  803. })
  804. }
  805. //获取表单效验数据
  806. const getFormRegExpJson = () => {
  807. return deepClone(formRegExpJson.value);
  808. }
  809. //获取当前展开项
  810. const getActiveKey = () => {
  811. return ActiveKey.value;
  812. }
  813. //设置当前展开项
  814. const setActiveKey = (key) => {
  815. return ActiveKey.value = key;
  816. }
  817. // 暴露出去
  818. defineExpose({
  819. getFormData,
  820. getFormRegExpJson,
  821. getActiveKey,
  822. setActiveKey
  823. })
  824. </script>
  825. <style lang="scss" scoped>
  826. .data-fill-list-box {
  827. position: relative;
  828. //margin-bottom: 25%;
  829. .hc-collapse-item-header {
  830. flex: 1;
  831. position: relative;
  832. margin-left: 46px;
  833. display: flex;
  834. align-items: center;
  835. .item-title {
  836. flex: 1;
  837. position: relative;
  838. user-select: none;
  839. color: #50545E;
  840. font-size: 16px;
  841. font-weight: 400;
  842. cursor: pointer;
  843. }
  844. .hc-extra-text-box {
  845. position: relative;
  846. padding-right: 24px;
  847. }
  848. }
  849. .data-fill-list-item-content {
  850. position: relative;
  851. display: flex;
  852. height: calc(100vh - 386px);
  853. .data-fill-table-form-box {
  854. position: relative;
  855. padding: 24px 20px;
  856. height: 100%;
  857. overflow: auto;
  858. flex: 1;
  859. .hc-no-table-form {
  860. position: relative;
  861. height: 100%;
  862. display: flex;
  863. justify-content: center;
  864. align-items: center;
  865. .table-form-no {
  866. position: relative;
  867. img {
  868. width: 350px;
  869. }
  870. .desc {
  871. text-align: center;
  872. font-size: 20px;
  873. color: #aaa;
  874. }
  875. }
  876. }
  877. }
  878. .data-fill-table-tip-box {
  879. width: 240px;
  880. position: relative;
  881. border-left: 1px solid #E9E9E9;
  882. padding: 20px 15px 80px;
  883. .tip-title {
  884. font-size: 16px;
  885. margin-bottom: 10px;
  886. display: flex;
  887. align-items: center;
  888. }
  889. .tip-item {
  890. margin-bottom: 20px;
  891. }
  892. .table-tip-foot {
  893. position: absolute;
  894. bottom: 15px;
  895. right: 0;
  896. left: 0;
  897. display: flex;
  898. align-items: center;
  899. padding: 0 15px;
  900. .tip-left-btn {
  901. flex: 1;
  902. .dow-text {
  903. cursor: pointer;
  904. display: flex;
  905. align-items: center;
  906. }
  907. }
  908. }
  909. }
  910. }
  911. }
  912. .special-box {
  913. position: relative;
  914. display: flex;
  915. justify-content: center;
  916. align-items: center;
  917. border: 1px solid #eee;
  918. border-radius: 3px;
  919. height: 52px;
  920. width: 52px;
  921. cursor: pointer;
  922. user-select: none;
  923. transition: color .3s, background-color .3s;
  924. &:hover {
  925. color: var(--el-color-primary);
  926. background-color: var(--el-color-primary-light-8);
  927. }
  928. .font-EUDC {
  929. font-size: 22px;
  930. }
  931. }
  932. .radio-group-box{
  933. text-align: center;
  934. }
  935. </style>
  936. <style lang="scss">
  937. .data-fill-list-box {
  938. .el-collapse {
  939. --el-collapse-header-height: 60px;
  940. border: 0;
  941. .el-collapse-item {
  942. margin: 0 0 16px;
  943. background-color: #f1f5f8;
  944. border: 1px solid #E9E9E9;
  945. border-radius: 4px;
  946. }
  947. .el-collapse-item__header {
  948. background-color: transparent;
  949. font-weight: 400;
  950. border-bottom: 0;
  951. cursor: default;
  952. font-size: 14px;
  953. .el-collapse-item__arrow {
  954. position: absolute;
  955. color: #50545E;
  956. cursor: pointer;
  957. left: 20px;
  958. margin: 0;
  959. }
  960. }
  961. .el-collapse-item.is-active .el-collapse-item__header.is-active {
  962. background-color: #E7EEF4;
  963. }
  964. .el-collapse-item__wrap {
  965. background-color: transparent;
  966. border-bottom: 0;
  967. .el-collapse-item__content {
  968. position: relative;
  969. padding-bottom: 0;
  970. font-size: 14px;
  971. color: #50545E;
  972. line-height: initial;
  973. }
  974. }
  975. }
  976. }
  977. //插入特殊字符弹窗的输入框
  978. .data-fill-list-box .data-fill-table-form-box td,
  979. .data-fill-list-box .data-fill-table-form-box td .el-input .el-input__wrapper .el-input__inner,
  980. .el-form-item.special-form-item .el-form-item__content .el-input .el-input__wrapper .el-input__inner {
  981. font-family: "EUDC", 宋体, v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  982. }
  983. //复制本表弹窗
  984. .copy-node-many-box {
  985. position: relative;
  986. height: 53vh;
  987. display: flex;
  988. margin-top: 24px;
  989. margin-bottom: -30px;
  990. border-top: 1px solid #efeff5;
  991. .copy-node-many-tree {
  992. position: relative;
  993. flex: 1;
  994. height: 100%;
  995. padding: 20px 20px 20px 0;
  996. border-right: 1px solid #efeff5;
  997. }
  998. .copy-node-many-table {
  999. position: relative;
  1000. flex: 1;
  1001. height: 100%;
  1002. padding: 20px 0 20px 20px;
  1003. }
  1004. }
  1005. </style>