add.vue 33 KB

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