add.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <!-- -->
  2. <template>
  3. <div class="hc-page-box">
  4. <HcNewCard ui="bgGray" style="overflow-y: auto;">
  5. <template #extra>
  6. <el-button
  7. hc-btn
  8. color="rgb(154, 154, 154)"
  9. style="color: white;"
  10. @click="goBack"
  11. >
  12. <HcIcon name="arrow-go-back" />
  13. <span>返回</span>
  14. </el-button>
  15. <el-button
  16. v-if="type !== 'view' && type !== 'review'"
  17. hc-btn
  18. color="#e54d42"
  19. style="color: white;"
  20. @click="clearInfo"
  21. >
  22. <HcIcon name="delete-bin-3" />
  23. <span>清空数据</span>
  24. </el-button>
  25. <el-button
  26. v-if="type === ''"
  27. hc-btn
  28. color="#12C060"
  29. style="color: white;"
  30. :loading="saveLoading"
  31. @click="saveInfo"
  32. >
  33. <HcIcon name="save" />
  34. <span>保存数据</span>
  35. </el-button>
  36. <el-button
  37. v-if="type === 'changeRow'"
  38. hc-btn
  39. color="#12C060"
  40. style="color: white;"
  41. :loading="changeRowLoaing"
  42. @click="changeRowInfo"
  43. >
  44. <HcIcon name="save" />
  45. <span>提交整改记录</span>
  46. </el-button>
  47. <el-button
  48. v-if="type === 'confirmChange'"
  49. hc-btn
  50. color="#12C060"
  51. style="color: white;"
  52. :loading="updateLoaing"
  53. @click="updateInfo"
  54. >
  55. <HcIcon name="save" />
  56. <span>确认修改</span>
  57. </el-button>
  58. <el-button
  59. v-if="type === 'review'"
  60. hc-btn
  61. color="#12C060"
  62. style="color: white;"
  63. :loading="reviewInspectLoaing"
  64. @click="reviewInspect(2)"
  65. >
  66. <HcIcon name="save" />
  67. <span>复核检查通过</span>
  68. </el-button>
  69. <el-button
  70. v-if="type === 'review'"
  71. hc-btn
  72. color="rgb(189, 49, 36)"
  73. style="color: white;"
  74. :loading="reviewInspectLoaing1"
  75. @click="reviewInspect(1)"
  76. >
  77. <HcIcon name="save" />
  78. <span>复核检查未通过</span>
  79. </el-button>
  80. </template>
  81. <el-form ref="addFormRef" :model="addForm" :rules="addRules" label-width="auto" size="large" label-position="left">
  82. <el-row :gutter="20">
  83. <el-col :span="12">
  84. <el-form-item label="检查名称" prop="inspectName">
  85. <el-input v-model="addForm.inspectName" placeholder="请输入" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12">
  89. <el-form-item label="检查类别" prop="inspectType">
  90. <el-select v-model="addForm.inspectType" placeholder="请选择" clearable style="width:100%" :disabled="type === 'changeRow' || type === 'review' || type === 'view'">
  91. <el-option v-for="item in typeOptions" :key="item.id" :label="item.dictValue" :value="item.dictKey" />
  92. </el-select>
  93. </el-form-item>
  94. </el-col>
  95. </el-row>
  96. <el-row :gutter="20">
  97. <el-col :span="12">
  98. <el-form-item label="是否需要整改" prop="isRectify">
  99. <el-radio-group v-model="addForm.isRectify" class="ml-4" :disabled="type === 'view'">
  100. <el-radio :label="1" size="large">需要整改</el-radio>
  101. <el-radio :label="2" size="large">不要整改</el-radio>
  102. </el-radio-group>
  103. </el-form-item>
  104. </el-col>
  105. </el-row>
  106. <el-row :gutter="20">
  107. <el-col :span="12">
  108. <el-form-item label="整改日期" prop="rectifyDate">
  109. <el-date-picker
  110. v-model="addForm.rectifyDate"
  111. type="date"
  112. value-format="YYYY-MM-DD"
  113. placeholder="请选择整改日期"
  114. :disabled="type === 'changeRow' || type === 'review' || type === 'view'"
  115. />
  116. </el-form-item>
  117. </el-col>
  118. </el-row>
  119. <el-row :gutter="20">
  120. <el-col :span="8">
  121. <el-form-item label="整改人" prop="rectifyUser">
  122. <HcTasksUser
  123. :disabled="type === 'changeRow' || type === 'review' || type === 'view'" :is-change-popele="true"
  124. :contract-id="contractId" :project-id="projectId" :users="peoples"
  125. ui="w-full" @change="tasksUserChange"
  126. />
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. <el-divider border-style="dashed" style="border: 1px dashed #cdd4e3;" />
  131. <el-row :gutter="20">
  132. <el-col :span="4">
  133. <el-form-item label="检查部位" prop="list">
  134. <el-button
  135. hc-btn
  136. type="primary"
  137. :disabled="type === 'changeRow' || type === 'review' || type === 'view'"
  138. @click="linksRelateModalClick"
  139. >
  140. <HcIcon name="add" />
  141. <span>点击选择</span>
  142. </el-button>
  143. </el-form-item>
  144. </el-col>
  145. </el-row>
  146. <div style="position: relative; height: 400px;margin-top: 20px;">
  147. <HcTable :column="tableColumn" :datas="processDataList">
  148. <template #inspectProject="{ row }">
  149. <hc-table-input v-model="row.inspectProject" type="textarea" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
  150. </template>
  151. <template #inspectContent="{ row }">
  152. <hc-table-input v-model="row.inspectContent" type="textarea" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
  153. </template>
  154. <template #deductionStandard="{ row }">
  155. <hc-table-input v-model="row.deductionStandard" type="textarea" :disabled="type === 'review' || type === 'view'" />
  156. </template>
  157. <template #rectifyFeedback="{ row }">
  158. <hc-table-input v-model="row.rectifyFeedback" type="textarea" :disabled="type === 'review' || type === 'view'" />
  159. </template>
  160. <template #rectifyAttachment="{ row, index }">
  161. <el-link v-if="row?.rectifyAttachmentName" type="primary" :disabled="type === 'review' || type === 'view'" @click="openAttachment(row)">{{ row.rectifyAttachmentName }}</el-link>
  162. <el-link v-else type="primary" @click="clickAttachment(row, index)">上传</el-link>
  163. </template>
  164. <template #inspectUserName="{ row }">
  165. <hc-table-input v-model="row.inspectUserName" type="textarea" :disabled="type === 'review' || type === 'view'" />
  166. </template>
  167. <template #inspectPdfUrl="{ row, index }">
  168. <el-link v-if="row?.isShowImage == 0" type="primary" :disabled="type === 'review' || type === 'view'" @click="clickUploadInspect(row, index)">上传</el-link>
  169. <el-image v-else style="width: 100px; height: 100px" :src="row?.inspectPdfUrl" />
  170. </template>
  171. <template #rectifyPdfUrl="{ row, index }">
  172. <el-link v-if="!row.rectifyPdfUrl" type="primary" :disabled="type === 'review' || type === 'view'" @click="clickRectifyPdfUrl(row, index)">上传</el-link>
  173. <el-image v-else style="width: 100px; height: 100px" :src="row.rectifyPdfUrl" />
  174. </template>
  175. <template #action="{ row, index }">
  176. <el-link type="danger" @click="deleProcess(row, index)">删除</el-link>
  177. </template>
  178. </HcTable>
  179. </div>
  180. </el-form>
  181. </HcNewCard>
  182. <hc-new-dialog :show="linksRelateModal" is-table save-text="确认关联" title="关联工程用途及部位" widths="50rem" @close="linksRelateModalClose" @save="linksRelateModalSave">
  183. <div class="hc-tree-box">
  184. <div class="hc-search-tree-val">
  185. <el-input v-model="searchTreeVal" block clearable placeholder="请输入名称关键词检索" @keyup="searchTreeKeyUp">
  186. <template #suffix>
  187. <HcIcon name="search-2" ui="text-xl iscusor" @click="searchTreeClick" />
  188. </template>
  189. </el-input>
  190. </div>
  191. <div id="hc-tree-scrollbar" v-loading="treeLoading" class="hc-tree-scrollbar" element-loading-text="获取数据中...">
  192. <el-scrollbar v-show="isSearchTree" class="scroll-bar-right-16">
  193. <div class=" node-many-tree">
  194. <HcDataTree
  195. :datas="searchTreeData"
  196. show-checkbox
  197. default-expand-all
  198. :default-checked-keys="defaultChecked"
  199. :auto-expand-keys="TreeAutoExpandKeys"
  200. check-strictly
  201. @nodeTap="wbsElTreeClick"
  202. @check="divisionTreeCheck"
  203. >
  204. <template #default="{ node, data }">
  205. <span style="font-size: 16px;">{{ data.title }}</span>
  206. </template>
  207. </HcDataTree>>
  208. </div>
  209. </el-scrollbar>
  210. <el-scrollbar v-show="!isSearchTree" class="scroll-bar-right-16">
  211. <div class=" node-many-tree">
  212. <HcLazyTree
  213. ref="processElTree"
  214. show-checkbox
  215. :default-checked-keys="defaultChecked"
  216. :auto-expand-keys="TreeAutoExpandKeys"
  217. check-strictly
  218. @check="divisionTreeCheck"
  219. @load="treeLoadNode"
  220. @nodeTap="wbsElTreeClick"
  221. >
  222. <template #default="{ node, data }">
  223. <span style="font-size: 16px;">{{ data.title }}</span>
  224. </template>
  225. </HcLazyTree>
  226. </div>
  227. </el-scrollbar>
  228. </div>
  229. </div>
  230. </hc-new-dialog>
  231. <HcUploadFile
  232. ref="HcUploadFileRef"
  233. :options="UploadFileOptions"
  234. :params="uploadFileParams"
  235. :echo-params="uploadFileEchoParams"
  236. @progress="HcUploadFileProgress"
  237. @success="HcUploadFileSuccess"
  238. @change="HcUploadFileChange"
  239. @finish="HcUploadFileFinish"
  240. />
  241. </div>
  242. </template>
  243. <script setup>
  244. import { onActivated, ref } from 'vue'
  245. import { useAppStore } from '~src/store'
  246. import queryApi from '~api/data-fill/query'
  247. import { arrToKey, formValidate, getArrValue, getObjValue } from 'js-fast-way'
  248. import { useRoute, useRouter } from 'vue-router'
  249. import { getTokenHeader } from '~src/api/request/header'
  250. import patrolApi from '~api/patrol/patrol'
  251. import { getDictionary } from '~api/other'
  252. //初始变量
  253. const router = useRouter()
  254. const useAppState = useAppStore()
  255. const useRoutes = useRoute()
  256. const routerQuery = useRoutes?.query
  257. const type = ref(routerQuery?.type || '')
  258. const id = ref(routerQuery?.id || '')
  259. const projectId = ref(useAppState.getProjectId)
  260. const contractId = ref(useAppState.getContractId)
  261. const addFormRef = ref(null)
  262. const addForm = ref({})
  263. const addRules = {
  264. inspectName: {
  265. required: true,
  266. trigger: 'blur',
  267. message: '请输入名称',
  268. },
  269. inspectType: {
  270. required: true,
  271. trigger: 'blur',
  272. message: '请选择类别',
  273. },
  274. isRectify: {
  275. required: true,
  276. trigger: 'blur',
  277. message: '请选择是否需要整改',
  278. },
  279. rectifyUser: {
  280. required: true,
  281. trigger: 'blur',
  282. message: '请选择整改人',
  283. },
  284. list: {
  285. required: true,
  286. trigger: 'blur',
  287. message: '请选择检查部位',
  288. },
  289. rectifyDate:{
  290. required: true,
  291. trigger: 'blur',
  292. message: '请选择整改时间',
  293. },
  294. }
  295. //检查类别
  296. const typeOptions = ref([
  297. // { label:'安全巡检', value:1 },
  298. // { label:'质量巡检', value:2 },
  299. ])
  300. //获取检查类别Data = ref([])
  301. const getTypeOptions = async () => {
  302. const { data } = await getDictionary({
  303. code: 'inspect_type',
  304. })
  305. //处理数据
  306. typeOptions.value = getArrValue(data)
  307. }
  308. const tableColumn = ref([
  309. { key: 'inspectProject', name: '检查项目' },
  310. { key: 'inspectContent', name: '检查内容' },
  311. { key: 'rectifyFeedback', name: '整改反馈' },
  312. { key: 'rectifyAttachment', name: '整改附件', width:150 },
  313. { key: 'inspectPdfUrl', name: '图片', width:150 },
  314. { key: 'action', name: '操作', width:100 },
  315. ])
  316. //整改显示列
  317. onActivated(()=>{
  318. getTypeOptions()
  319. const routerQuery = useRoutes?.query
  320. type.value = routerQuery?.type || ''
  321. id.value = routerQuery?.id || ''
  322. if (id.value.length > 0) {
  323. getDetail( id.value)
  324. } else {
  325. addForm.value = {}
  326. processDataList.value = []
  327. peoples.value = ''
  328. }
  329. if (type.value === 'changeRow') {
  330. tableColumn.value = [
  331. { key: 'inspectProject', name: '检查项目' },
  332. { key: 'inspectContent', name: '检查内容' },
  333. { key: 'rectifyFeedback', name: '整改反馈' },
  334. { key: 'rectifyAttachment', name: '整改附件', width:150 },
  335. { key: 'rectifyPdfUrl', name: '图片', width:150 },
  336. { key: 'action', name: '操作', width:100 },
  337. ]
  338. } else if (type.value === 'review') {
  339. tableColumn.value = [
  340. { key: 'inspectProject', name: '检查项目' },
  341. { key: 'inspectContent', name: '检查内容' },
  342. { key: 'deductionStandard', name: '扣分标准' },
  343. { key: 'inspectUserName', name: '检查人名称' },
  344. { key: 'inspectPdfUrl', name: '图片', width:150 },
  345. { key: 'rectifyFeedback', name: '整改反馈' },
  346. { key: 'rectifyAttachment', name: '整改附件', width:150 },
  347. { key: 'rectifyPdfUrl', name: '整改后图片', width:150 },
  348. ]
  349. } else {
  350. tableColumn.value = [
  351. { key: 'inspectProject', name: '检查项目' },
  352. { key: 'inspectContent', name: '检查内容' },
  353. { key: 'deductionStandard', name: '扣分标准' },
  354. { key: 'inspectUserName', name: '检查人名称' },
  355. { key: 'inspectPdfUrl', name: '图片', width:150 },
  356. { key: 'action', name: '操作', width:100 },
  357. ]
  358. }
  359. })
  360. //获取巡检详情
  361. const getDetail = async (id)=>{
  362. const { error, code, data } = await patrolApi.detail({
  363. id:id,
  364. })
  365. //判断状态
  366. if (!error && code === 200) {
  367. console.log(data, 'data')
  368. addForm.value = getObjValue(data)
  369. processDataList.value = addForm.value.list
  370. peoples.value = addForm.value.rectifyUser
  371. } else {
  372. addForm.value = {}
  373. processDataList.value = []
  374. }
  375. }
  376. const HcUploadFileRef = ref(null)
  377. //上传配置
  378. const UploadFileOptions = ref({})
  379. //上传检查图片
  380. const clickUploadInspect = (row, index)=>{
  381. UploadFileOptions.value = {
  382. url: '/api/blade-resource/oss/endpoint/put-file',
  383. accept: 'image/png,image/jpg,image/jpeg',
  384. accept_tip: 'png、jpg、jpeg',
  385. headers: getTokenHeader(),
  386. multiple: false,
  387. }
  388. HcUploadFileRef.value?.cancelUpload()
  389. HcUploadFileRef.value?.selectFile()
  390. uploadFileEchoParams.value = { type:'image', index:index }
  391. }
  392. //上传整改图片
  393. const clickRectifyPdfUrl = (row, index)=>{
  394. UploadFileOptions.value = {
  395. url: '/api/blade-resource/oss/endpoint/put-file',
  396. accept: 'image/png,image/jpg,image/jpeg',
  397. accept_tip: 'png、jpg、jpeg',
  398. headers: getTokenHeader(),
  399. multiple: false,
  400. }
  401. setTimeout(() => {
  402. HcUploadFileRef.value?.selectFile()
  403. }, 1000)
  404. HcUploadFileRef.value?.cancelUpload()
  405. // HcUploadFileRef.value?.selectFile()
  406. uploadFileEchoParams.value = { type:'rectify', index:index }
  407. }
  408. //上传整改附件
  409. const clickAttachment = (row, index)=>{
  410. UploadFileOptions.value = {
  411. url: '/api/blade-resource/oss/endpoint/put-file',
  412. accept: 'application/pdf,.doc,.docx,application/msword',
  413. accept_tip: 'PDF<br/>Word(doc、docx)',
  414. headers: getTokenHeader(),
  415. multiple: false,
  416. }
  417. HcUploadFileRef.value?.cancelUpload()
  418. setTimeout(() => {
  419. HcUploadFileRef.value?.selectFile()
  420. }, 500)
  421. uploadFileEchoParams.value = { type:'attachment', index:index }
  422. }
  423. const openAttachment = (row)=>{
  424. if (row?.rectifyAttachment) {
  425. window.open(row?.rectifyAttachment, '_blank')
  426. } else {
  427. window.$message?.warning('获取PDF失败')
  428. }
  429. }
  430. const uploadFileParams = ref({})
  431. const uploadFileEchoParams = ref({})
  432. // 文件上传进度
  433. const HcUploadFileProgress = (res) => {
  434. console.log('文件上传进度', res)
  435. }
  436. // 文件上传成功的回调
  437. const HcUploadFileSuccess = ({ echoParams, resData }) => {
  438. if (echoParams['type'] === 'image' && resData?.link) {
  439. setUploadImage(echoParams, resData)
  440. } else if (echoParams['type'] === 'attachment' && resData?.link) {
  441. setAttchment(echoParams, resData)
  442. } else if (echoParams['type'] === 'rectify' && resData?.link) {
  443. setRectify(echoParams, resData)
  444. }
  445. }
  446. //设置上传图片
  447. const setUploadImage = (echoParams, resData)=>{
  448. processDataList.value[echoParams['index']].isShowImage = 1
  449. processDataList.value[echoParams['index']].inspectPdfUrl = resData?.link
  450. }
  451. //这种上传整改图片
  452. const setRectify = (echoParams, resData)=>{
  453. console.log(resData, 'resData11111')
  454. processDataList.value[echoParams['index']].rectifyPdfUrl = resData?.link
  455. }
  456. //设置上传附件
  457. const setAttchment = (echoParams, resData)=>{
  458. console.log(resData, 'resData11111')
  459. processDataList.value[echoParams['index']].rectifyAttachmentName = resData?.originalName
  460. processDataList.value[echoParams['index']].rectifyAttachment = resData?.link
  461. }
  462. // 文件全部上传成功
  463. const HcUploadFileChange = () => {
  464. console.log('文件全部上传成功')
  465. }
  466. const HcUploadFileFinish = ()=>{
  467. HcUploadFileRef.value?.setModalShow(false)
  468. }
  469. //选择整改人
  470. const peoples = ref('')
  471. //任务人选择改变
  472. const tasksUserChange = (a, b, users) => {
  473. addForm.value.rectifyUser = users
  474. }
  475. //关联工程用途及部位
  476. const linksRelateModal = ref(false)
  477. const linksRelateModalClick = ()=>{
  478. TreeAutoExpandKeys.value = processDataList.value[0]?.autoExpandKeys || []
  479. linksRelateModal.value = true
  480. isSearchTree.value = false
  481. defaultChecked.value = arrToKey(processDataList.value, 'primaryKeyId', ',').split(',')
  482. }
  483. const linksRelateModalClose = ()=>{
  484. linksRelateModal.value = false
  485. }
  486. const processDataList = ref([])
  487. const linksRelateModalSave = ()=>{
  488. console.log('baocun', processDataList.value )
  489. console.log(defaultChecked.value, 'defaultChecked.value')
  490. const keys = processElTree.value.treeRef.getCheckedKeys()
  491. // const keys = defaultChecked.value
  492. console.log(keys, 'keys')
  493. let linkTabIds = processDataList.value
  494. if (keys.length === 0) {
  495. linkTabIds = []
  496. }
  497. //去出掉取消勾选的
  498. for (let index = 0; index < keys.length; index++) {
  499. linkTabIds = linkTabIds.filter((ele)=>{
  500. if (ele.primaryKeyId === keys[index]) {
  501. return ele
  502. }
  503. })
  504. }
  505. for (let index = 0; index < keys.length; index++) {
  506. console.log(keys[index], 'keys[index]')
  507. let node = processElTree.value.treeRef.getNode(keys[index])
  508. console.log(node, 'NODE')
  509. let pathArr = []
  510. getKeys(node, pathArr)
  511. TreeAutoExpandKeys.value = pathArr
  512. linkTabIds.push({
  513. inspectProject: node.data.title,
  514. primaryKeyId: keys[index],
  515. autoExpandKeys:TreeAutoExpandKeys.value,
  516. isShowImage:0,
  517. })
  518. }
  519. //去除掉重复的
  520. getNorepeatArr(linkTabIds)
  521. console.log(linkTabIds, 'linkTabIds')
  522. console.log(processDataList.value, 'processDataList.value')
  523. linkTabIds.forEach((ele)=>{
  524. processDataList.value.forEach((ele1)=>{
  525. if (ele.primaryKeyId === ele1.primaryKeyId) {
  526. ele.isShowImage = ele1.isShowImage
  527. ele.inspectContent = ele1.inspectContent
  528. ele.deductionStandard = ele1.deductionStandard
  529. ele.inspectUserName = ele1.inspectUserName
  530. ele.inspectPdfUrl = ele1.inspectPdfUrl
  531. ele.autoExpandKeys = ele1.autoExpandKeys
  532. }
  533. })
  534. })
  535. console.log(linkTabIds, 'linkTabIds1111')
  536. processDataList.value = linkTabIds
  537. linksRelateModal.value = false
  538. addForm.value.list = linkTabIds
  539. }
  540. //获取展开节点
  541. const getKeys = (node, pathArr) => {
  542. if (node.parent) {
  543. pathArr.unshift(node.data?.primaryKeyId.replace(/(^\s*)|(\s*$)/g, '')) //去掉头尾空格
  544. getKeys(node.parent, pathArr)
  545. } else {
  546. return //根节点结束
  547. }
  548. }
  549. const getNorepeatArr = (tempArr)=> {
  550. let newArr = []
  551. for (let i = 0; i < tempArr.length; i++) {
  552. if (newArr.indexOf(tempArr[i].primaryKeyId) == -1) {
  553. newArr.push(tempArr[i].primaryKeyId)
  554. } else {
  555. tempArr.splice(i, 1)
  556. i--
  557. }
  558. }
  559. return tempArr
  560. }
  561. //移除工序
  562. const deleProcess = (row, index) => {
  563. const linkTabIds = processDataList.value
  564. linkTabIds.splice(index, 1)
  565. processDataList.value = linkTabIds
  566. }
  567. const searchTreeVal = ref('')
  568. const isSearchTree = ref(false)
  569. const searchTreeHeight = ref()
  570. //回车
  571. const searchTreeKeyUp = (e) => {
  572. if (e.key === 'Enter') {
  573. searchTreeClick()
  574. }
  575. }
  576. const searchTreeClick = async () => {
  577. if (searchTreeVal.value) {
  578. searchTreeHeight.value = document.getElementById('hc-tree-scrollbar').offsetHeight
  579. isSearchTree.value = true
  580. //treeLoading.value = true
  581. getSearchTreeData().then()
  582. } else {
  583. isSearchTree.value = false
  584. }
  585. }
  586. //回车
  587. const searchTreeData = ref([])
  588. const treeLoading = ref(false)
  589. const getSearchTreeData = async () => {
  590. treeLoading.value = true
  591. const { error, code, data } = await queryApi.getTreeNodeByQueryValueAndContractId({
  592. contractId: contractId.value,
  593. queryValue: searchTreeVal.value,
  594. tableOwner:1,
  595. })
  596. //判断状态
  597. if (!error && code === 200) {
  598. let treedata = getArrValue(data)
  599. searchTreeData.value = treedata
  600. treeLoading.value = false
  601. } else {
  602. treeLoading.value = false
  603. searchTreeData.value = []
  604. }
  605. }
  606. const wbsElTreeClick = ({ node, data, keys })=>{
  607. console.log(keys, 'keys')
  608. TreeAutoExpandKeys.value = keys || []
  609. }
  610. //懒加载的数据
  611. const treeLoadNode = async ({ node, item, level }, resolve) => {
  612. let contractIdRelation = '', parentId = '', primaryKeyId = ''
  613. if (level !== 0) {
  614. const nodeData = getObjValue(item)
  615. contractIdRelation = nodeData?.contractIdRelation || ''
  616. parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
  617. primaryKeyId = nodeData?.id || ''
  618. }
  619. //获取数据
  620. const { data } = await queryApi.queryWbsTreeData({
  621. contractId: contractId.value || '',
  622. contractIdRelation,
  623. primaryKeyId,
  624. parentId,
  625. // classifyType: contractTypeTabKey.value,
  626. classifyType:1,
  627. tableOwner:1,
  628. })
  629. resolve(getArrValue(data))
  630. }
  631. const divisionTreeCheck = () => {
  632. }
  633. const defaultChecked = ref([]) //默认选中
  634. const TreeAutoExpandKeys = ref([])//默认展开
  635. const processElTree = ref(null)
  636. const goList = ()=>{
  637. router.push({
  638. path: '/patrol/safe',
  639. })
  640. }
  641. const goBack = ()=>{
  642. router.back()
  643. }
  644. //保存数据
  645. const saveLoading = ref(false)
  646. const saveInfo = async ()=>{
  647. const validate = await formValidate(addFormRef.value)
  648. if (validate) {
  649. console.log(addForm.value, '数据')
  650. addForm.value.projectId = projectId.value
  651. addForm.value.list = processDataList.value
  652. saveLoading.value = true
  653. const { error, code } = await patrolApi.add(
  654. addForm.value,
  655. )
  656. saveLoading.value = false
  657. if (!error && code === 200) {
  658. window?.$message?.success('操作成功')
  659. goList()
  660. }
  661. }
  662. }
  663. //修改数据
  664. const updateLoaing = ref(false)
  665. const updateInfo = async ()=>{
  666. const validate = await formValidate(addFormRef.value)
  667. if (validate) {
  668. console.log(addForm.value, '数据')
  669. addForm.value.projectId = projectId.value
  670. addForm.value.list = processDataList.value
  671. updateLoaing.value = true
  672. const { error, code } = await patrolApi.update(
  673. addForm.value,
  674. )
  675. updateLoaing.value = false
  676. if (!error && code === 200) {
  677. window?.$message?.success('操作成功')
  678. goList()
  679. }
  680. }
  681. }
  682. //清除数据
  683. const clearInfo = ()=>{
  684. processDataList.value = []
  685. addForm.value = {}
  686. peoples.value = ''
  687. addForm.value.id = id.value
  688. }
  689. //提交整改记录
  690. const changeRowLoaing = ref(false)
  691. const changeRowInfo = async ()=>{
  692. const validate = await formValidate(addFormRef.value)
  693. if (validate) {
  694. console.log(addForm.value, '数据')
  695. addForm.value.projectId = projectId.value
  696. addForm.value.list = processDataList.value
  697. changeRowLoaing.value = true
  698. const { error, code } = await patrolApi.submitRectify(
  699. addForm.value,
  700. )
  701. changeRowLoaing.value = false
  702. if (!error && code === 200) {
  703. window?.$message?.success('操作成功')
  704. }
  705. }
  706. }
  707. //复核检测
  708. const reviewInspectLoaing = ref(false)
  709. const reviewInspectLoaing1 = ref(false)
  710. const reviewInspect = async (type)=>{
  711. if (type === 2) {
  712. reviewInspectLoaing.value = true
  713. } else if (type === 1) {
  714. reviewInspectLoaing1.value = false
  715. }
  716. const { error, code } = await patrolApi.reviewInspect(
  717. { id:id.value,
  718. status:type },
  719. )
  720. reviewInspectLoaing.value = false
  721. reviewInspectLoaing1.value = false
  722. if (!error && code === 200) {
  723. window?.$message?.success('操作成功')
  724. goList()
  725. }
  726. }
  727. </script>
  728. <style lang='scss' scoped>
  729. .bgGray{
  730. background-color: rgba(32, 77, 161, 0.08);;
  731. }
  732. .hc-table-form-content .hc-content-box .hc-table-forem-box .hc-fixed-page {
  733. .el-button {
  734. display: block;
  735. margin: 20px;
  736. }
  737. }
  738. </style>
  739. <style lang='scss' scoped>
  740. .hc-process-box {
  741. position: relative;
  742. flex: 1;
  743. overflow: hidden;
  744. .hc-scrollbar-box {
  745. display: contents;
  746. }
  747. .process-item-box {
  748. position: relative;
  749. color: #838791;
  750. font-size: 14px;
  751. padding: 8px 0;
  752. display: flex;
  753. align-items: flex-start;
  754. .process-item {
  755. position: relative;
  756. flex: 1;
  757. }
  758. .process-icon {
  759. font-size: 20px;
  760. cursor: pointer;
  761. margin-left: 16px;
  762. transition: color 0.2s;
  763. &:hover {
  764. color: var(--el-color-primary-light-3);
  765. }
  766. }
  767. }
  768. .process-item-box + .process-item-box {
  769. border-top: 0.5px solid #e9e9e9;
  770. }
  771. }
  772. </style>