add.vue 31 KB

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