detail.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  1. <template>
  2. <basic-container>
  3. <div class="h-100p">
  4. <el-tabs
  5. v-model="activeType"
  6. :before-leave="beforeLeave"
  7. >
  8. <el-tab-pane
  9. label="项目基本信息"
  10. name="1"
  11. :disabled="btnLoad"
  12. >
  13. <div>
  14. <el-form
  15. :model="projectForm"
  16. :rules="projectRules"
  17. ref="projectForm"
  18. label-width="120px"
  19. >
  20. <el-row>
  21. <el-col :span="12">
  22. <el-form-item
  23. label="项目名称"
  24. prop="projectName"
  25. >
  26. <el-input v-model="projectForm.projectName"></el-input>
  27. </el-form-item>
  28. <el-form-item
  29. label="项目别名"
  30. prop="projectAlias"
  31. >
  32. <el-input v-model="projectForm.projectAlias"></el-input>
  33. </el-form-item>
  34. <el-form-item
  35. label="项目编号"
  36. prop="projectNumber"
  37. >
  38. <el-input v-model="projectForm.projectNumber"></el-input>
  39. </el-form-item>
  40. <el-form-item
  41. label="公路等级"
  42. prop="projectGrade"
  43. >
  44. <el-select
  45. v-model="projectForm.projectGrade"
  46. placeholder="请选择"
  47. class="w-100p"
  48. >
  49. <el-option
  50. v-for="item in highwayGradeList"
  51. :key="item.id"
  52. :label="item.dictValue"
  53. :value="item.dictKey"
  54. ></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item
  58. label="计划开工日期"
  59. prop="planStartTime"
  60. >
  61. <el-date-picker
  62. v-model="projectForm.planStartTime"
  63. type="date"
  64. format="yyyy 年 MM 月 dd 日"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. placeholder="选择日期"
  67. ></el-date-picker>
  68. </el-form-item>
  69. <el-form-item
  70. label="实际开工日期"
  71. prop="actualStartTime"
  72. >
  73. <el-date-picker
  74. v-model="projectForm.actualStartTime"
  75. type="date"
  76. format="yyyy 年 MM 月 dd 日"
  77. value-format="yyyy-MM-dd HH:mm:ss"
  78. placeholder="选择日期"
  79. ></el-date-picker>
  80. </el-form-item>
  81. <el-form-item
  82. label="项目预算投资"
  83. prop="estimatedAmount"
  84. >
  85. <el-input v-model="projectForm.estimatedAmount">
  86. <template slot="append">万元</template>
  87. </el-input>
  88. </el-form-item>
  89. <el-form-item
  90. label="电签类别"
  91. prop="remarkType"
  92. >
  93. <el-radio-group v-model="projectForm.remarkType">
  94. <el-radio :label="1">安心签</el-radio>
  95. <el-radio :label="2">东方中讯</el-radio>
  96. </el-radio-group>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="12">
  100. <el-form-item
  101. label="项目概况"
  102. prop="projectGist"
  103. >
  104. <el-input
  105. v-model="projectForm.projectGist"
  106. type="textarea"
  107. :rows="7"
  108. ></el-input>
  109. </el-form-item>
  110. <el-form-item
  111. label="内置里程"
  112. prop="projectAllMileage"
  113. >
  114. <el-radio-group v-model="radioType">
  115. <el-radio-button label="总里程"></el-radio-button>
  116. <el-radio-button label="路面"></el-radio-button>
  117. <el-radio-button label="路基"></el-radio-button>
  118. </el-radio-group>
  119. <el-input-number
  120. v-model="projectForm.projectAllMileage"
  121. v-show="radioType == '总里程'"
  122. :min="0"
  123. label="总里程"
  124. ></el-input-number>
  125. <el-input-number
  126. v-model="projectForm.projectPavement"
  127. v-show="radioType == '路面'"
  128. :min="0"
  129. label="路面"
  130. ></el-input-number>
  131. <el-input-number
  132. v-model="projectForm.projectSubgrade"
  133. v-show="radioType == '路基'"
  134. :min="0"
  135. label="路基"
  136. ></el-input-number>
  137. <span>公里(KM)</span>
  138. </el-form-item>
  139. <el-form-item
  140. label="计划完工日期"
  141. prop="planEndTime"
  142. >
  143. <el-date-picker
  144. v-model="projectForm.planEndTime"
  145. type="date"
  146. format="yyyy 年 MM 月 dd 日"
  147. value-format="yyyy-MM-dd HH:mm:ss"
  148. placeholder="选择日期"
  149. ></el-date-picker>
  150. </el-form-item>
  151. <el-form-item
  152. label="实际完工日期"
  153. prop="actualEndTime"
  154. >
  155. <el-date-picker
  156. v-model="projectForm.actualEndTime"
  157. type="date"
  158. format="yyyy 年 MM 月 dd 日"
  159. value-format="yyyy-MM-dd HH:mm:ss"
  160. placeholder="选择日期"
  161. ></el-date-picker>
  162. </el-form-item>
  163. <el-form-item
  164. label="开启随机数"
  165. prop="isOpenRandomNumber"
  166. >
  167. <el-radio-group v-model="projectForm.isOpenRandomNumber">
  168. <el-radio :label="0">不开启</el-radio>
  169. <el-radio :label="1">开启</el-radio>
  170. </el-radio-group>
  171. </el-form-item>
  172. <el-form-item v-if="false"
  173. label="是否为省级模板"
  174. prop="isOpenRandomNumber"
  175. >
  176. <el-radio-group v-model="projectForm.isOpenRandomNumber" >
  177. <el-radio :label="1">是</el-radio>
  178. <el-radio :label="0">否</el-radio>
  179. </el-radio-group>
  180. </el-form-item>
  181. </el-col>
  182. </el-row>
  183. </el-form>
  184. </div>
  185. </el-tab-pane>
  186. <el-tab-pane
  187. label="分配WBS模版"
  188. name="2"
  189. :disabled="btnLoad"
  190. >
  191. <div>
  192. <div class="text-align-c">
  193. <el-radio-group
  194. v-model="templateType"
  195. @change="templateTypeChange"
  196. >
  197. <el-radio :label="2">试验</el-radio>
  198. <el-radio :label="1">质检</el-radio>
  199. <el-radio :label="5">征拆</el-radio>
  200. </el-radio-group>
  201. </div>
  202. <div class="text-align-c mg-t-20" >
  203. <span class="mg-r-20">选择WBS</span>
  204. <el-select
  205. v-model="wbsId"
  206. @change='wbsChange'
  207. :disabled="iswbsselected"
  208. placeholder="请选择WBS"
  209. style="width:500px;"
  210. >
  211. <el-option-group
  212. v-for="group in treeList"
  213. :key="group.label"
  214. :label="group.label"
  215. >
  216. <el-option
  217. v-for="(item,index) in group.options"
  218. :key="index"
  219. :label="item.label"
  220. :value="item.value"
  221. >
  222. </el-option>
  223. </el-option-group>
  224. </el-select>
  225. </div>
  226. <tree-tree
  227. :left-tree-data="leftTreeData"
  228. scrollbarStyle="height:calc(100vh - 500px)"
  229. ref="treetotree"
  230. :show-all-check="true"
  231. @onAddTree="treeChang"
  232. @onDelTree="treeChang"
  233. @onCheckAll="treeChang"
  234. :leftloading="leftloading"
  235. :rightloading="rightloading"
  236. ></tree-tree>
  237. </div>
  238. </el-tab-pane>
  239. <el-tab-pane
  240. label="分配日志WBS"
  241. name="3"
  242. :disabled="btnLoad"
  243. >
  244. <div>
  245. <div class="text-align-c mg-t-20">
  246. <span class="mg-r-20">选择WBS</span>
  247. <el-select
  248. v-model="logWbsId"
  249. @change="logWbsChange"
  250. :disabled="selected"
  251. placeholder="请选择WBS"
  252. style="width:500px;"
  253. >
  254. <el-option-group
  255. v-for="group in logTreeList"
  256. :key="group.label"
  257. :label="group.label"
  258. >
  259. <el-option
  260. v-for="(item,index) in group.options"
  261. :key="index"
  262. :label="item.label"
  263. :value="item.value"
  264. >
  265. </el-option>
  266. </el-option-group>
  267. </el-select>
  268. </div>
  269. <tree-tree
  270. :left-tree-data="logLeftTreeData"
  271. ref="treetotree2"
  272. :show-all-check="true"
  273. @onAddTree="treeChang3"
  274. @onDelTree="treeChang3"
  275. @onCheckAll="treeChang3"
  276. :leftloading="logleftloading"
  277. :rightloading="logrightloading"
  278. scrollbarStyle="height:calc(100vh - 500px)"
  279. ></tree-tree>
  280. </div>
  281. </el-tab-pane>
  282. <el-tab-pane
  283. label="分配系统维护人员"
  284. name="4"
  285. :disabled="btnLoad"
  286. >
  287. <div>
  288. <div class="flex jc-al-c">
  289. <span class="mg-r-10">项目名称</span>
  290. <el-input
  291. v-model="projectForm.projectName"
  292. disabled
  293. style="width:300px;margin-right:30px;"
  294. ></el-input>
  295. <span class="mg-r-10">合同段名称</span>
  296. <el-select
  297. v-model="cId"
  298. placeholder="请选择"
  299. @change="getUserByCondition"
  300. >
  301. <el-option
  302. label="全部"
  303. value=""
  304. ></el-option>
  305. <el-option
  306. v-for="item in contractList"
  307. :key="item.id"
  308. :label="item.contractName"
  309. :value="item.id"
  310. ></el-option>
  311. </el-select>
  312. </div>
  313. <el-divider></el-divider>
  314. <div class="flex jc-al-c mg-b-10">
  315. <span>维护人员角色</span>
  316. <avue-input-tree
  317. class="marleft10"
  318. :check-strictly="true"
  319. v-model="rId"
  320. placeholder="请选择"
  321. type="tree"
  322. :dic="roleList"
  323. :props="treeProps"
  324. @change="getUserByCondition"
  325. ></avue-input-tree>
  326. <!-- <el-select v-model="rId" clearable placeholder="请选择" @change="getUserByCondition">
  327. <el-option v-for="item in roleList" :key="item.id" :label="item.title" :value="item.id"></el-option>
  328. </el-select> -->
  329. </div>
  330. <div>
  331. <el-table
  332. :data="contractUserList"
  333. border
  334. height="420"
  335. style="width: 100%"
  336. >
  337. <el-table-column
  338. prop="name"
  339. label="姓名"
  340. align="center"
  341. ></el-table-column>
  342. <el-table-column
  343. prop="contractName"
  344. label="合同段名称"
  345. align="center"
  346. ></el-table-column>
  347. <el-table-column
  348. prop="postName"
  349. label="岗位"
  350. align="center"
  351. ></el-table-column>
  352. <el-table-column
  353. prop="phone"
  354. label="电话"
  355. align="center"
  356. ></el-table-column>
  357. <el-table-column
  358. label="操作"
  359. align="center"
  360. >
  361. <template slot-scope="scope">
  362. <el-button
  363. size="mini"
  364. type="danger"
  365. @click="handleDelete(scope.$index, scope.row)"
  366. >删除</el-button>
  367. </template>
  368. </el-table-column>
  369. </el-table>
  370. </div>
  371. <div class="martop10 flexEnd">
  372. <el-pagination
  373. background
  374. @size-change="handleSizeChange"
  375. @current-change="handleCurrentChange"
  376. :current-page.sync="pageindx"
  377. :page-size="pagesize"
  378. layout="total, prev, pager, next"
  379. :total="total"
  380. >
  381. </el-pagination>
  382. </div>
  383. <div class="flex jc-al-c mg-t-20">
  384. <span>添加系统内部人员</span>
  385. <el-select
  386. class="marleft10"
  387. v-model="userId"
  388. filterable
  389. placeholder="请输入搜索"
  390. >
  391. <el-option
  392. v-for="item in userList"
  393. :key="item.id"
  394. :label="item.name"
  395. :value="item.id"
  396. ></el-option>
  397. </el-select>
  398. <el-button
  399. type="success"
  400. class="marleft10"
  401. @click="addUserToProject"
  402. >添加</el-button>
  403. <el-button
  404. type="primary"
  405. @click="rputerPush()"
  406. >创建新用户</el-button>
  407. <el-button
  408. type="danger"
  409. @click="handleDeletes"
  410. >全部删除</el-button>
  411. </div>
  412. <el-divider></el-divider>
  413. </div>
  414. </el-tab-pane>
  415. </el-tabs>
  416. <div class="flexEnd">
  417. <el-button
  418. :type="activeType != 4?'info':'success'"
  419. size="medium"
  420. :disabled="saveBtnDisabled
  421. || leftloading || logleftloading
  422. || rightloading || logrightloading"
  423. :loading="saveBtnLoad"
  424. @click="saveQuit"
  425. >保存并退出</el-button>
  426. <el-button
  427. type="info"
  428. size="medium"
  429. :disabled="saveBtnBackDisabled
  430. || leftloading || logleftloading
  431. || rightloading || logrightloading"
  432. :loading="saveBtnBackLoad"
  433. v-if="activeType != 1"
  434. @click="saveNext('p')"
  435. >保存并返回上一步</el-button>
  436. <el-button
  437. type="success"
  438. size="medium"
  439. :disabled="saveBtnNextDisabled
  440. || leftloading || logleftloading
  441. || rightloading || logrightloading"
  442. :loading="saveBtnNextLoad"
  443. v-if="activeType != 4"
  444. @click="saveNext('n')"
  445. >保存并进入下一步</el-button>
  446. </div>
  447. </div>
  448. </basic-container>
  449. </template>
  450. <script>
  451. import {
  452. submitProject, getProjectDeatil, findWbsTreeList, findProjectTree,
  453. submitWbsTreeInProject, getProjectDeatilWbsId, findLogWbsTreeList, submitLogWbsTreeInProject
  454. } from "@/api/manager/projectinfo";
  455. import {
  456. findContractByProjectId, saveUserInfoByProject, findUserListByCondition,
  457. findUserByName, removeUsersByIds
  458. } from "@/api/manager/contractinfo";
  459. import { getRoleTree } from "@/api/system/role";
  460. import { getAlltree } from "@/api/manager/wbstree";
  461. import { getDictionary } from "@/api/system/dict";
  462. import { mapGetters } from "vuex";
  463. import treeTree from "@/components/tree-tree/main"
  464. import { findUserList } from "@/api/manager/contractinfo";
  465. export default {
  466. components: {
  467. treeTree
  468. },
  469. data () {
  470. var checkDate = (rule, value, callback) => {
  471. if (value && this.projectForm.planStartTime) {
  472. if (Date.parse(value) < Date.parse(this.projectForm.planStartTime)) {
  473. callback(new Error('计划完工日期不能小于开工日期'));
  474. }
  475. }
  476. callback();
  477. };
  478. var checkDate2 = (rule, value, callback) => {
  479. if (value && this.projectForm.actualStartTime) {
  480. if (Date.parse(value) < Date.parse(this.projectForm.actualStartTime)) {
  481. callback(new Error('实际完工日期不能小于开工日期'));
  482. }
  483. }
  484. callback();
  485. };
  486. var checkIsNumber = (rule, value, callback) => {
  487. if (value != Number(value)) {
  488. callback(new Error('金额必须是数字'));
  489. }
  490. if (value && 999999999999999999 < Number(value)) {
  491. callback(new Error('数字过大'));
  492. }
  493. callback();
  494. };
  495. var checkMileage = (rule, value, callback) => {
  496. if (this.projectForm.projectPavement || this.projectForm.projectSubgrade) {
  497. if (this.projectForm.projectPavement) {
  498. if (this.projectForm.projectPavement > value) {
  499. callback(new Error('总里程必须是最大的'));
  500. }
  501. } else if (this.projectForm.projectSubgrade) {
  502. if (this.projectForm.projectSubgrade > value) {
  503. callback(new Error('总里程必须是最大的'));
  504. }
  505. }
  506. if (this.projectForm.projectPavement && this.projectForm.projectSubgrade) {
  507. if ((this.projectForm.projectPavement + this.projectForm.projectSubgrade) > value) {
  508. callback(new Error('总里程必须大于两项总和'));
  509. }
  510. }
  511. }
  512. callback();
  513. };
  514. return {
  515. //#region
  516. pageindx: 1,
  517. pagesize: 10,
  518. total: 0,
  519. //#endregion
  520. activeType: '1',
  521. typeChang: {
  522. 1: false,
  523. 2: false,
  524. 3: false,
  525. 4: false,
  526. },
  527. btnLoad: false,
  528. saveBtnLoad: false,
  529. saveBtnDisabled: false,
  530. saveBtnBackLoad: false,
  531. saveBtnBackDisabled: false,
  532. saveBtnNextLoad: false,
  533. saveBtnNextDisabled: false,
  534. id: '',
  535. highwayGradeList: [],
  536. radioType: '总里程',
  537. projectForm: {
  538. estimatedAmount: 0,
  539. isOpenRandomNumber:1
  540. },
  541. projectRules: {
  542. projectName: [
  543. { required: true, message: '请输入项目名称', trigger: 'blur' },
  544. ],
  545. projectAlias: [
  546. { required: true, message: '请输入项目别名', trigger: 'blur' },
  547. ],
  548. planStartTime: [{ required: true, message: '请选择计划开工日期', trigger: 'blur' },],
  549. planEndTime: [
  550. { validator: checkDate, trigger: 'blur' }
  551. ],
  552. actualEndTime: [
  553. { validator: checkDate2, trigger: 'blur' }
  554. ],
  555. estimatedAmount: [
  556. { validator: checkIsNumber, trigger: 'blur' }
  557. ],
  558. projectAllMileage: [
  559. { validator: checkMileage, trigger: 'blur' }
  560. ],
  561. remarkType: [
  562. { required: true, message: '请选择电签类别', trigger: 'blur' },
  563. ]
  564. },
  565. contractList: [],
  566. cId: '',
  567. rId: '',
  568. roleList: [],
  569. userId: '',
  570. userList: [],
  571. contractUserList: [],
  572. treeProps: {
  573. label: "dictValue",
  574. value: "id"
  575. },
  576. templateType: 1,
  577. treeList: [],
  578. logTreeList: [],
  579. wbsId: '',
  580. iswbsselected:true,//右边有数据禁用下拉框选择
  581. logWbsId: '',
  582. selected: false,
  583. leftTreeData: [],
  584. logLeftTreeData: [],
  585. leftloading:false,
  586. rightloading:false,
  587. logleftloading:false,
  588. logrightloading:false,
  589. selectData:{},
  590. isFirst:false,
  591. rightTreeData:[],//存储右边的试验树数据
  592. rightTreeData1:[],//存储右边的质检树数据
  593. rightTreeData2:[],//存储征拆数据
  594. rightObj:[
  595. ],
  596. rightObj1:[
  597. ],
  598. rightObj2:[
  599. ],
  600. nowref:{},
  601. finalWbsid:'',
  602. finalIds:''
  603. }
  604. },
  605. computed: {
  606. ...mapGetters(["userInfo"]),
  607. },
  608. watch: {
  609. projectForm: {
  610. immediate:false,
  611. handler: function () { // 此处注意,handler函数不能为箭头函数,this会取上下文,而不是组件里的this,此外,深度监听,必须为handler函数名,否则会无效果
  612. // this.typeChang['1'] = true;
  613. if(this.isFirst===false){
  614. this.typeChang['1'] = true;
  615. }
  616. },
  617. deep: true
  618. },
  619. activeType: function (newValue) {
  620. if (newValue == '4') {
  621. this.getContractList();
  622. this.getRoleList();
  623. this.getUserByCondition();
  624. this.getUserByName();
  625. } else if (newValue == '2') {
  626. this.treeInit();
  627. } else if (newValue == '3') {
  628. this.treeLogInit();
  629. }
  630. }
  631. },
  632. created () {
  633. this.init();
  634. //console.log(this.userInfo)
  635. },
  636. mounted () {
  637. this.$nextTick(() => {
  638. this.typeChang = {
  639. 1: false,
  640. 2: false,
  641. 3: false,
  642. 4: false,
  643. }
  644. })
  645. },
  646. methods: {
  647. //#region //后加分页
  648. handleSizeChange (val) {
  649. this.pagesize = val
  650. this.getUserByCondition();
  651. },
  652. handleCurrentChange (val) {
  653. this.pageindx = val
  654. this.getUserByCondition();
  655. },
  656. rputerPush () {
  657. this.$router.push({
  658. path: '/system/user',
  659. query: { tankai: true }
  660. })
  661. },
  662. //#endregion
  663. init () {
  664. this.getHighwayGradeList();
  665. this.id = this.$route.query.id;
  666. if (this.id) {
  667. this.getProjectDeatil();
  668. }
  669. },
  670. beforeLeave (activeName, oldActiveName) {
  671. return new Promise((resolve, reject) => {
  672. if (oldActiveName == '1' && !this.projectForm.id) {
  673. this.$message({
  674. type: "warning",
  675. message: "请先保存项目后,再进行项目的分配"
  676. });
  677. // reject();
  678. }
  679. if (this.typeChang[oldActiveName]) {
  680. this.$confirm('检测到新编辑内容, 是否保存?', '提示', {
  681. confirmButtonText: '确定',
  682. cancelButtonText: '不用',
  683. type: 'warning'
  684. }).then(() => {
  685. switch (oldActiveName) {
  686. case '1':
  687. this.saveProject().then((res) => {
  688. this.projectForm.id = res.data.data.id;
  689. this.typeChang[oldActiveName] = false;
  690. resolve();
  691. this.$message({
  692. type: "success",
  693. message: "保存成功!"
  694. });
  695. });
  696. break;
  697. case '2':
  698. this.saveWbsTree().then(() => {
  699. this.typeChang[oldActiveName] = false;
  700. resolve();
  701. this.$message({
  702. type: "success",
  703. message: "保存成功!"
  704. });
  705. }).catch(() => {
  706. console.log("beforeLeave catch getRightTree")
  707. this.getRightTree();
  708. reject();
  709. })
  710. break;
  711. }
  712. }).catch(() => {
  713. this.typeChang[oldActiveName] = false;
  714. resolve();
  715. })
  716. } else {
  717. resolve();
  718. }
  719. })
  720. },
  721. getProjectDeatil () {
  722. getProjectDeatil(this.id).then((res) => {
  723. const data = res.data.data
  724. console.log(data)
  725. this.projectForm = data;
  726. this.isFirst=true;
  727. setTimeout(() => {
  728. this.isFirst=false;
  729. }, 1000);
  730. console.log(data,'data项目详情');
  731. this.selectData={
  732. referenceWbsTemplateId:data.referenceWbsTemplateId,//质检
  733. referenceWbsTemplateIdLar:data.referenceWbsTemplateIdLar,//征拆
  734. referenceWbsTemplateIdTrial:data.referenceWbsTemplateIdTrial===-1?'':data.referenceWbsTemplateIdTrial//试验
  735. }
  736. if (Number(this.projectForm.estimatedAmount) < 0) {
  737. this.projectForm.estimatedAmount = 0
  738. }
  739. this.$nextTick(() => {
  740. this.typeChang['1'] = false;
  741. })
  742. let templateType = 'public';
  743. if (this.projectForm.referenceWbsTemplateType) {
  744. templateType = this.projectForm.referenceWbsTemplateType;
  745. }
  746. getProjectDeatilWbsId(this.id, this.projectForm.referenceWbsTemplateId, templateType).then((res) => {
  747. this.projectForm.wbsType = res.data.data.wbsType;
  748. })
  749. })
  750. },
  751. async saveQuit () {
  752. console.log('保存2',this.selectData);
  753. this.btnLoad = true;
  754. this.saveBtnLoad = true;
  755. this.saveBtnBackDisabled = true
  756. this.saveBtnNextDisabled = true
  757. try {
  758. if (this.activeType == '1') {
  759. await this.saveProject();
  760. } else if (this.activeType == '2') {
  761. await this.saveWbsTree();
  762. } else if (this.activeType == '3'){
  763. await this.saveLogWbsTree();
  764. }
  765. } catch (error) {
  766. this.btnLoad = false;
  767. this.saveBtnLoad = false;
  768. this.saveBtnBackDisabled = false
  769. this.saveBtnNextDisabled = false
  770. if(this.activeType == '2'){
  771. console.log("saveQuit getRightTree")
  772. this.getRightTree();
  773. }
  774. return;
  775. }
  776. this.$message({
  777. type: "success",
  778. message: "保存成功!"
  779. });
  780. this.btnLoad = false;
  781. this.saveBtnLoad = false;
  782. this.saveBtnBackDisabled = false
  783. this.saveBtnNextDisabled = false
  784. this.$router.go(-1);
  785. },
  786. async saveNext (type) {
  787. console.log('保存',this.activeType,this.selectData);
  788. this.btnLoad = true;
  789. if (type == 'n') {
  790. this.saveBtnNextLoad = true;
  791. this.saveBtnBackDisabled = true
  792. this.saveBtnDisabled = true
  793. } else if (type == 'p') {
  794. this.saveBtnBackLoad = true;
  795. this.saveBtnNextDisabled = true
  796. this.saveBtnDisabled = true
  797. }
  798. try {
  799. if (this.activeType == '1') {
  800. let res = await this.saveProject();
  801. this.projectForm.id = res.data.data.id;
  802. } else if (this.activeType == '2') {
  803. await this.saveWbsTree();
  804. } else if (this.activeType == '3'){
  805. await this.saveLogWbsTree();
  806. }
  807. } catch (error) {
  808. this.btnLoad = false;
  809. if (type == 'n') {
  810. this.saveBtnNextLoad = false;
  811. this.saveBtnBackDisabled = false
  812. this.saveBtnDisabled = false
  813. } else if (type == 'p') {
  814. this.saveBtnBackLoad = false;
  815. this.saveBtnNextDisabled = false
  816. this.saveBtnDisabled = false
  817. }
  818. if(this.activeType == '2'){
  819. console.log("saveNext getRightTree")
  820. this.getRightTree();
  821. }
  822. return;
  823. }
  824. this.$message({
  825. type: "success",
  826. message: "保存成功!"
  827. });
  828. this.typeChang[this.activeType] = false;
  829. let num = Number(this.activeType);
  830. if (type == 'n') {
  831. num++;
  832. } else if (type == 'p') {
  833. num--;
  834. }
  835. this.activeType = num.toString();
  836. this.btnLoad = false;
  837. if (type == 'n') {
  838. this.saveBtnNextLoad = false;
  839. this.saveBtnBackDisabled = false
  840. this.saveBtnDisabled = false
  841. } else if (type == 'p') {
  842. this.saveBtnBackLoad = false;
  843. this.saveBtnNextDisabled = false
  844. this.saveBtnDisabled = false
  845. }
  846. },
  847. saveProject () {
  848. console.log('保存3',this.selectData);
  849. return new Promise((resolve, reject) => {
  850. this.$refs['projectForm'].validate((valid) => {
  851. if (valid) {
  852. resolve(submitProject(this.projectForm))
  853. } else {
  854. reject('验证失败')
  855. }
  856. })
  857. })
  858. },
  859. saveLogWbsTree() {
  860. let ids = this.$refs.treetotree2.getTreeAllId('rightTree');
  861. let obj = {
  862. wbsId: this.logWbsId,
  863. projectId: this.projectForm.id,
  864. wbsType: "4",
  865. wbsTreeIds: ids
  866. };
  867. return submitLogWbsTreeInProject(obj);
  868. },
  869. saveWbsTree () {
  870. let obj = {};
  871. let ids = this.$refs.treetotree.getTreeAllId('rightTree');
  872. // if(this.finalWbsid.length>0){
  873. // this.wbsId=this.finalWbsid
  874. // }
  875. console.log(this.finalIds,'finalIds');
  876. obj = {
  877. wbsId: this.wbsId,
  878. projectId: this.projectForm.id,
  879. wbsType: this.templateType,
  880. wbsTreeIds: ids
  881. }
  882. console.log(this.wbsId,'this.wbsId最终');
  883. console.log(this.projectForm,'projectForm');
  884. if (this.wbsId.toString().indexOf(',') >= 0) {
  885. //私有库
  886. obj.referenceType = "private";
  887. let ids = this.wbsId.toString().split(',');
  888. // obj.wbsId = this.finalWbsid;
  889. obj.wbsId = ids[0];
  890. obj.referencePrivateWbsProjectId = ids[1];
  891. obj.primaryKeyId = this.leftTreeData[0].primaryKeyId;
  892. } else {
  893. //公有库
  894. obj.referenceType = "public";
  895. obj.wbsId = this.wbsId;
  896. // obj.wbsId = this.finalWbsid;
  897. }
  898. return submitWbsTreeInProject(obj);
  899. },
  900. addUserToProject () {
  901. if (!this.userId) {
  902. this.$message({
  903. type: "warning",
  904. message: "请先选择用户再进行添加"
  905. });
  906. return;
  907. }
  908. if (!this.rId) {
  909. this.$message({
  910. type: "warning",
  911. message: "请先选择维护人员角色再进行添加"
  912. });
  913. return;
  914. }
  915. let list = [{
  916. projectId: this.projectForm.id,
  917. contractId: this.cId ? this.cId : undefined,
  918. userId: this.userId,
  919. roleId: this.rId
  920. }];
  921. saveUserInfoByProject(list).then(() => {
  922. this.getUserByCondition();
  923. })
  924. },
  925. getUserByCondition () {
  926. findUserListByCondition({
  927. cId: this.cId,
  928. pId: this.projectForm.id,
  929. postId: '',
  930. rId: this.rId,
  931. size: this.pagesize,
  932. current: this.pageindx
  933. }).then((res) => {
  934. this.contractUserList = res.data.data.records;
  935. this.total = res.data.data.total
  936. })
  937. },
  938. getUserByName () {
  939. findUserList('').then((res) => {
  940. this.userList = res.data.data;
  941. })
  942. },
  943. handleDelete (index, row) {
  944. this.$confirm('是否将该用户移除出合同段', '提示', {
  945. confirmButtonText: '确定',
  946. cancelButtonText: '取消',
  947. type: 'warning'
  948. }).then(() => {
  949. removeUsersByIds(row.id).then(() => {
  950. this.contractUserList.splice(index, 1);
  951. this.$message({
  952. type: "success",
  953. message: "删除成功!"
  954. });
  955. })
  956. })
  957. },
  958. handleDeletes () {
  959. this.$confirm('是否将所有用户移除出合同段', '提示', {
  960. confirmButtonText: '确定',
  961. cancelButtonText: '取消',
  962. type: 'warning'
  963. }).then(() => {
  964. let ids = [];
  965. this.contractUserList.forEach((element) => {
  966. ids.push(element.id);
  967. })
  968. removeUsersByIds(ids.join(',')).then(() => {
  969. this.contractUserList = [];
  970. this.$message({
  971. type: "success",
  972. message: "删除成功!"
  973. });
  974. })
  975. })
  976. },
  977. getHighwayGradeList () {
  978. if (this.highwayGradeList.length > 1) {
  979. return;
  980. }
  981. getDictionary({
  982. code: 'highway_grade'
  983. }).then((res) => {
  984. // res.data.data.forEach(element => {
  985. // element.dictKey = Number(element.dictKey)
  986. // });
  987. this.highwayGradeList = res.data.data;
  988. })
  989. },
  990. getContractList () {
  991. if (this.contractList.length < 1) {
  992. findContractByProjectId(this.projectForm.id).then((res) => {
  993. this.contractList = res.data.data;
  994. })
  995. }
  996. },
  997. getRoleList () {
  998. if (this.roleList.length > 1) {
  999. return;
  1000. }
  1001. getRoleTree().then((res) => {
  1002. this.roleList = res.data.data
  1003. })
  1004. },
  1005. logWbsChange(value){
  1006. //公有库
  1007. this.logleftloading = true;
  1008. getAlltree(this.userInfo.tenant_id, '1', value).then((res) => {
  1009. if (Array.isArray(res.data.data)) {
  1010. this.logLeftTreeData = res.data.data;
  1011. } else {
  1012. this.logLeftTreeData = [];
  1013. }
  1014. this.logleftloading = false;
  1015. })
  1016. },
  1017. wbsChange (value, flag) {
  1018. console.log(value, 'WBS节点更换测试 value')
  1019. this.iswbsselected=false
  1020. if(this.templateType==1){
  1021. this.selectData.referenceWbsTemplateId=value
  1022. }else if(this.templateType==5){
  1023. // this.selectData.referenceWbsTemplateId=value
  1024. this.selectData.referenceWbsTemplateIdLar=value
  1025. }
  1026. else{
  1027. this.selectData.referenceWbsTemplateIdTrial=value
  1028. }
  1029. this.leftloading = true;
  1030. if (value&&value.toString().indexOf(',') >= 0) {
  1031. console.log('私有库');
  1032. //私有库
  1033. if(this.templateType==1){
  1034. this.projectForm.referenceWbsTemplateType='private'
  1035. }else if(this.templateType==5){
  1036. this.projectForm.referenceWbsTemplateTypeLar='private'
  1037. }
  1038. else{
  1039. this.projectForm.referenceWbsTemplateTypeTrial='private'
  1040. }
  1041. let ids = value.toString().split(',');
  1042. console.log(ids,'ids');
  1043. findProjectTree(ids[1], ids[0]).then((res) => {
  1044. if (Array.isArray(res.data.data)) {
  1045. this.leftTreeData = res.data.data;
  1046. } else {
  1047. this.leftTreeData = [];
  1048. }
  1049. this.leftloading = false;
  1050. })
  1051. this.getRightTree()
  1052. } else {
  1053. console.log('公有库');
  1054. //公有库
  1055. if(value&&value.length>0){
  1056. if(this.templateType==1){
  1057. this.projectForm.referenceWbsTemplateType='public'
  1058. }
  1059. else if(this.templateType==5){
  1060. this.projectForm.referenceWbsTemplateTypeLar='public'
  1061. }else{
  1062. this.projectForm.referenceWbsTemplateTypeTrial='public'
  1063. }
  1064. }
  1065. getAlltree(this.userInfo.tenant_id, '1', value).then((res) => {
  1066. if (Array.isArray(res.data.data)) {
  1067. this.leftTreeData = res.data.data;
  1068. console.log("this.leftTreeData", this.leftTreeData)
  1069. } else {
  1070. this.leftTreeData = [];
  1071. }
  1072. this.leftloading = false;
  1073. })
  1074. this.getRightTree()
  1075. }
  1076. if (flag === undefined) { /* 下拉框切换的时候调用 */
  1077. this.getRightTree();
  1078. }
  1079. },
  1080. getLogTreeList(){
  1081. return new Promise((resolve) => {
  1082. if (this.logTreeList.length) {
  1083. resolve();
  1084. }
  1085. findLogWbsTreeList().then((res) => {
  1086. let arr = [{
  1087. label: '公有库',
  1088. options: [],
  1089. }];
  1090. let data = res.data.data;
  1091. if (data && data.length) {
  1092. data.forEach((element) => {
  1093. element.label = element.wbsName;
  1094. element.value = element.id;
  1095. })
  1096. arr[0].options = data;
  1097. }
  1098. this.logTreeList = arr;
  1099. }).finally(() => {
  1100. resolve();
  1101. })
  1102. })
  1103. },
  1104. getTreeList () {
  1105. console.log('getTreeList');
  1106. return new Promise((resolve) => {
  1107. if (this.treeList.length) {
  1108. resolve();
  1109. }
  1110. findWbsTreeList(this.templateType).then((res) => {
  1111. let arr = [{
  1112. label: '公有库',
  1113. options: [],
  1114. },
  1115. {
  1116. label: '私有库',
  1117. options: [],
  1118. }];
  1119. let data = res.data.data;
  1120. if (data.wbsInfos && data.wbsInfos.length) {
  1121. data.wbsInfos.forEach((element) => {
  1122. element.label = element.wbsName;
  1123. element.value = element.id;
  1124. })
  1125. arr[0].options = data.wbsInfos;
  1126. }
  1127. if (data.wbsTreePrivates && data.wbsTreePrivates.length) {
  1128. data.wbsTreePrivates.forEach((element) => {
  1129. element.label = element.projectName;
  1130. element.value = element.wbsId + ',' + element.projectId;
  1131. })
  1132. arr[1].options = data.wbsTreePrivates;
  1133. }
  1134. this.treeList = arr;
  1135. // this.wbsChange(this.wbsId, true)
  1136. }).finally(() => {
  1137. resolve();
  1138. })
  1139. })
  1140. },
  1141. //格式化wbsid
  1142. formatWbsId(orid){
  1143. let refId = orid;
  1144. let WbsId=''
  1145. if ((this.templateType == 1 && this.projectForm.referenceWbsTemplateType === 'private')
  1146. || (this.templateType == 2 && this.projectForm.referenceWbsTemplateTypeTrial === 'private')
  1147. || (this.templateType == 5 && this.projectForm.referenceWbsTemplateTypeLar === 'private')
  1148. && refId != null && refId.toString().length > 0) {
  1149. console.log(refId,'refId');
  1150. // 私有库右边树形数据是通过 pkeyId 查询的
  1151. let ids = refId.toString().split(",");
  1152. console.log(ids,'ids');
  1153. if (ids.length > 1) {
  1154. refId = ids[0]
  1155. console.log(refId,'refId');
  1156. console.log(this.treeList,'treeList');
  1157. let list = this.treeList[1].options;
  1158. refId = list.filter(e => e.projectId == ids[1])[0].pkeyId;
  1159. WbsId=refId
  1160. }
  1161. }else{
  1162. console.log(3333333);
  1163. WbsId=refId
  1164. }
  1165. return WbsId
  1166. },
  1167. treeChang () {
  1168. let recordid= this.formatWbsId(this.wbsId)
  1169. console.log(recordid,'recordid');
  1170. if (this.templateType===2) {
  1171. this.rightTreeData=this.$refs.treetotree.rightTreeData;
  1172. // this.rightObj.push({
  1173. // wbsid:this.wbsId,objdata: this.rightTreeData
  1174. // })
  1175. this.rightObj.wbsId=recordid
  1176. this.rightObj.objdata=this.rightTreeData
  1177. }else if(this.templateType===5){
  1178. this.rightTreeData2=this.$refs.treetotree.rightTreeData
  1179. this.rightObj2.wbsId=recordid
  1180. this.rightObj2.objdata=this.rightTreeData2
  1181. }
  1182. else{
  1183. this.rightTreeData1=this.$refs.treetotree.rightTreeData
  1184. // this.rightObj1.push({
  1185. // wbsid:this.wbsId,objdata: this.rightTreeData
  1186. // })
  1187. this.rightObj1.wbsId=recordid
  1188. this.rightObj1.objdata=this.rightTreeData1
  1189. }
  1190. this.typeChang[2] = true;
  1191. },
  1192. treeChang3 () {
  1193. this.typeChang[3] = true;
  1194. },
  1195. templateTypeChange () {
  1196. findWbsTreeList(this.templateType).then((res) => {
  1197. let arr = [
  1198. {label: '公有库', options: []},
  1199. {label: '私有库', options: []}
  1200. ];
  1201. let data = res.data.data;
  1202. if (data.wbsInfos && data.wbsInfos.length) {
  1203. data.wbsInfos.forEach((element) => {
  1204. element.label = element.wbsName;
  1205. element.value = element.id;
  1206. })
  1207. arr[0].options = data.wbsInfos;
  1208. }
  1209. if (data.wbsTreePrivates && data.wbsTreePrivates.length) {
  1210. data.wbsTreePrivates.forEach((element) => {
  1211. element.label = element.projectName;
  1212. element.value = element.wbsId + ',' + element.projectId;
  1213. })
  1214. arr[1].options = data.wbsTreePrivates;
  1215. }
  1216. this.treeList = arr;
  1217. this.wbsId = this.templateType == 1 ? this.selectData.referenceWbsTemplateId : this.selectData.referenceWbsTemplateIdTrial
  1218. if(this.templateType===5){
  1219. console.log('征拆选择');
  1220. this.wbsId =this.selectData.referenceWbsTemplateIdLar
  1221. }
  1222. console.log(this.wbsId===-1);
  1223. if(this.wbsId===-1){
  1224. this.wbsId=''
  1225. }
  1226. this.wbsChange(this.wbsId, true)
  1227. // if(this.treeList[0].options.length > 0){
  1228. // this.wbsId = this.treeList[0].options[0].value;
  1229. // this.wbsChange(this.wbsId)
  1230. // }else if(this.treeList[1].options.length > 0){
  1231. // this.wbsId = this.treeList[1].options[0].value;
  1232. // this.wbsChange(this.wbsId)
  1233. // }else{
  1234. // this.wbsId = '';
  1235. // this.leftTreeData = [];
  1236. // }
  1237. })
  1238. },
  1239. async treeLogInit(){
  1240. let refId = this.projectForm.referenceLogWbsTemplateId;
  1241. if(refId && refId > 0 && Number(this.projectForm.wbsType) > 0){
  1242. await this.getLogTreeList();
  1243. this.logWbsId = refId;
  1244. this.logleftloading = true;
  1245. let leftData = await getAlltree(this.userInfo.tenant_id, '1', refId);
  1246. if (Array.isArray(leftData.data.data)) {
  1247. this.logLeftTreeData = leftData.data.data;
  1248. } else {
  1249. this.logLeftTreeData = [];
  1250. }
  1251. this.logleftloading = false;
  1252. this.logrightloading = true;
  1253. let projectTree = await findProjectTree(this.projectForm.id, refId);
  1254. this.$refs.treetotree2.setRightTree(Array.isArray(projectTree.data.data)?projectTree.data.data:[]);
  1255. this.logrightloading = false;
  1256. } else {
  1257. await this.getLogTreeList();
  1258. }
  1259. },
  1260. //初始化质量
  1261. async treeInit () {
  1262. console.log('------------------- treeInit ------------------------');
  1263. let refId = this.selectData.referenceWbsTemplateId;
  1264. console.log(refId, '------------------- treeInit.refId ------------------------');
  1265. if (this.projectForm.referenceWbsTemplateType === 'private' && refId != null && refId.toString().length > 0) {
  1266. // 私有库右边树形数据是通过 pkeyId 查询的
  1267. let ids = refId.toString().split(",");
  1268. if (ids.length > 1) {
  1269. refId = ids[0]
  1270. let list = this.treeList[1].options;
  1271. refId = list.filter(e => e.projectId == ids[1])[0].pkeyId;
  1272. }
  1273. }
  1274. //引用被删会出现 wbsType -1
  1275. if (refId && refId > 0 && Number(this.projectForm.wbsType) > 0) {
  1276. console.log('------------------- treeInit if------------------------');
  1277. //有引用id,回显
  1278. //this.selected = true;
  1279. this.templateType = this.projectForm.wbsType;
  1280. await this.getTreeList();
  1281. let priv = {};
  1282. if (this.projectForm.referenceWbsTemplateType == 'private') {
  1283. //私有
  1284. let list = this.treeList[1].options;
  1285. for (let i = 0; i < list.length; i++) {
  1286. if (list[i].pkeyId == refId) {
  1287. this.wbsId = list[i].wbsId + ',' + list[i].projectId;
  1288. priv.wbsId = list[i].wbsId;
  1289. priv.projectId = list[i].projectId;
  1290. priv.value= list[i].value
  1291. priv.pkeyId= list[i].pkeyId
  1292. break;
  1293. }
  1294. }
  1295. } else {
  1296. //公有
  1297. this.wbsId = refId;
  1298. }
  1299. if(this.templateType == 1){
  1300. this.selectData.referenceWbsTemplateId =this.wbsId
  1301. }else if(this.templateType==5){
  1302. this.selectData.referenceWbsTemplateIdLar =this.wbsId
  1303. }
  1304. else{
  1305. this.selectData.referenceWbsTemplateIdTrial=this.wbsId
  1306. }
  1307. this.nowref={
  1308. value:priv.value,
  1309. id: priv.pkeyId
  1310. }
  1311. let projectTree = await findProjectTree(this.projectForm.id, refId) //查询的右边的数据
  1312. if (projectTree&&projectTree.data&&projectTree.data.data&&projectTree.data.data.length>0) {
  1313. this.iswbsselected=true
  1314. }else{
  1315. this.iswbsselected=false
  1316. }
  1317. if (Array.isArray(projectTree.data.data)) {
  1318. this.leftloading = true;
  1319. this.rightloading = true;
  1320. if (this.projectForm.referenceWbsTemplateType == 'private') {
  1321. //私有
  1322. let leftData = await findProjectTree(priv.projectId, priv.wbsId)
  1323. if (Array.isArray(leftData.data.data)) {
  1324. this.leftTreeData = leftData.data.data;
  1325. } else {
  1326. this.leftTreeData = [];
  1327. }
  1328. this.leftloading = false;
  1329. } else {
  1330. //公有
  1331. let leftData = await getAlltree(this.userInfo.tenant_id, '1', refId)
  1332. if (Array.isArray(leftData.data.data)) {
  1333. this.leftTreeData = leftData.data.data;
  1334. } else {
  1335. this.leftTreeData = [];
  1336. }
  1337. this.leftloading = false;
  1338. }
  1339. this.$refs.treetotree.setRightTree(projectTree.data.data);
  1340. console.log(projectTree.data.data,'projectTree.data.data');
  1341. this.rightloading = false;
  1342. }else{
  1343. this.wbsId = '';
  1344. }
  1345. }
  1346. else {
  1347. console.log('------------------- treeInit else------------------------');
  1348. this.getTreeList();
  1349. this.iswbsselected=false
  1350. }
  1351. console.log(this.wbsId,'this.wbsId33333');
  1352. this.treeInitTrial()
  1353. this.treeInitLar()
  1354. },
  1355. //初始化征拆
  1356. async treeInitLar () {
  1357. let refId = this.selectData.referenceWbsTemplateIdLar;
  1358. console.log(refId,'refId');
  1359. //引用被删会出现 wbsType -1
  1360. if (refId && refId > 0 && Number(this.projectForm.wbsType) > 0) {
  1361. //有引用id,回显
  1362. //this.selected = true;
  1363. findWbsTreeList(5).then((res) => {
  1364. let arr = [{
  1365. label: '公有库',
  1366. options: [],
  1367. },
  1368. {
  1369. label: '私有库',
  1370. options: [],
  1371. }];
  1372. let data = res.data.data;
  1373. if (data.wbsInfos && data.wbsInfos.length) {
  1374. data.wbsInfos.forEach((element) => {
  1375. element.label = element.wbsName;
  1376. element.value = element.id;
  1377. })
  1378. arr[0].options = data.wbsInfos;
  1379. }
  1380. if (data.wbsTreePrivates && data.wbsTreePrivates.length) {
  1381. data.wbsTreePrivates.forEach((element) => {
  1382. element.label = element.projectName;
  1383. element.value = element.wbsId + ',' + element.projectId;
  1384. })
  1385. arr[1].options = data.wbsTreePrivates;
  1386. }
  1387. let WbsId = 0;
  1388. if (this.projectForm.referenceWbsTemplateTypeLar == 'private') {
  1389. //私有
  1390. let list = arr[1].options;
  1391. console.log(list,'list');
  1392. for (let i = 0; i < list.length; i++) {
  1393. if (list[i].pkeyId == refId) {
  1394. WbsId = list[i].wbsId + ',' + list[i].projectId;
  1395. break;
  1396. }
  1397. }
  1398. } else {
  1399. console.log('共有',refId);
  1400. //公有
  1401. WbsId = refId;
  1402. }
  1403. this.selectData.referenceWbsTemplateIdLar = WbsId
  1404. console.log("征拆", this.selectData)
  1405. })
  1406. } else {
  1407. this.getTreeList();
  1408. }
  1409. },
  1410. //初始化试验
  1411. async treeInitTrial () {
  1412. let refId = this.selectData.referenceWbsTemplateIdTrial;
  1413. //引用被删会出现 wbsType -1
  1414. if (refId && refId > 0 && Number(this.projectForm.wbsType) > 0) {
  1415. //有引用id,回显
  1416. //this.selected = true;
  1417. findWbsTreeList(2).then((res) => {
  1418. let arr = [{
  1419. label: '公有库',
  1420. options: [],
  1421. },
  1422. {
  1423. label: '私有库',
  1424. options: [],
  1425. }];
  1426. let data = res.data.data;
  1427. if (data.wbsInfos && data.wbsInfos.length) {
  1428. data.wbsInfos.forEach((element) => {
  1429. element.label = element.wbsName;
  1430. element.value = element.id;
  1431. })
  1432. arr[0].options = data.wbsInfos;
  1433. }
  1434. if (data.wbsTreePrivates && data.wbsTreePrivates.length) {
  1435. data.wbsTreePrivates.forEach((element) => {
  1436. element.label = element.projectName;
  1437. element.value = element.wbsId + ',' + element.projectId;
  1438. })
  1439. arr[1].options = data.wbsTreePrivates;
  1440. }
  1441. let WbsId = 0;
  1442. if (this.projectForm.referenceWbsTemplateTypeTrial == 'private') {
  1443. //私有
  1444. let list = arr[1].options;
  1445. for (let i = 0; i < list.length; i++) {
  1446. if (list[i].pkeyId == refId) {
  1447. WbsId = list[i].wbsId + ',' + list[i].projectId;
  1448. break;
  1449. }
  1450. }
  1451. } else {
  1452. //公有
  1453. WbsId = refId;
  1454. }
  1455. this.selectData.referenceWbsTemplateIdTrial = WbsId
  1456. console.log("treeInitTrial", this.selectData)
  1457. })
  1458. } else {
  1459. this.getTreeList();
  1460. }
  1461. },
  1462. getRightTree() {
  1463. this.rightloading = true;
  1464. this.iswbsselected=true
  1465. console.log(this.nowref,'nowrefId');
  1466. let refId = this.templateType === 1? this.selectData.referenceWbsTemplateId : this.selectData.referenceWbsTemplateIdTrial;
  1467. if(this.templateType===5){
  1468. console.log(this.selectData.referenceWbsTemplateIdLar,1111111111);
  1469. refId=this.selectData.referenceWbsTemplateIdLar;
  1470. // this.$refs.treetotree.setRightTree([]);
  1471. }
  1472. console.log(refId,'refId');
  1473. if(!refId){
  1474. console.log('不存在refId');
  1475. this.$refs.treetotree.setRightTree([]);
  1476. this.iswbsselected=false
  1477. }else{
  1478. let WbsId=''
  1479. if (this.projectForm.referenceWbsTemplateType === 'private' && refId != null && refId.toString().length > 0
  1480. ||this.projectForm.referenceWbsTemplateTypeLar === 'private' && refId != null && refId.toString().length > 0) {
  1481. // 私有库右边树形数据是通过 pkeyId 查询的
  1482. let ids = refId.toString().split(",");
  1483. console.log(ids,'ids111111');
  1484. this.finalIds=ids
  1485. if (ids.length > 1) {
  1486. refId = ids[0]
  1487. let list = this.treeList[1].options;
  1488. refId = list.filter(e => e.projectId == ids[1])[0].pkeyId;
  1489. console.log(refId,'refId');
  1490. }
  1491. }
  1492. //引用被删会出现 wbsType -1
  1493. if (refId && refId > 0) {
  1494. let priv = {};
  1495. if (this.projectForm.referenceWbsTemplateType == 'private'||this.projectForm.referenceWbsTemplateTypeLar === 'private' ) {
  1496. //私有
  1497. let list = this.treeList[1].options;
  1498. for (let i = 0; i < list.length; i++) {
  1499. if (list[i].pkeyId == refId) {
  1500. refId = list[i].wbsId + ',' + list[i].projectId;
  1501. priv.wbsId = list[i].wbsId;
  1502. priv.projectId = list[i].projectId;
  1503. priv.value= list[i].value
  1504. priv.pkeyId= list[i].pkeyId
  1505. break;
  1506. }
  1507. }
  1508. } else {
  1509. //公有
  1510. WbsId = refId;
  1511. }
  1512. if(this.nowref.value===refId){
  1513. console.log(11111111111);
  1514. WbsId=this.nowref.id
  1515. }else{
  1516. if (this.projectForm.referenceWbsTemplateType == 'private'&& refId != null && refId.toString().length > 0 ||this.projectForm.referenceWbsTemplateTypeLar === 'private'&& refId != null && refId.toString().length > 0) {
  1517. WbsId = priv.pkeyId||this.selectData.referenceWbsTemplateIdTrial
  1518. }
  1519. else {//公有
  1520. WbsId=this.templateType === 1 ?this.selectData.referenceWbsTemplateId: this.selectData.referenceWbsTemplateIdTrial
  1521. if(this.templateType===5){
  1522. WbsId=this.selectData.referenceWbsTemplateIdLar
  1523. }
  1524. }
  1525. }
  1526. this.finalWbsid=WbsId
  1527. console.log(WbsId,'WbsId');
  1528. console.log( this.finalWbsid,' this.finalWbsid=');
  1529. // this.selectData.referenceWbsTemplateIdLar=WbsId
  1530. console.log(this.selectData.referenceWbsTemplateIdLar,'this.selectData.referenceWbsTemplateIdLar');
  1531. // findProjectTree(this.projectForm.id, this.templateType === 1 ? WbsId : this.selectData.referenceWbsTemplateIdTrial).then((res) => {
  1532. findProjectTree(this.projectForm.id, WbsId).then((res) => {
  1533. if (this.rightTreeData.length>0&&this.templateType===2&&this.rightObj.wbsId==WbsId) {
  1534. this.$refs.treetotree.setRightTree(this.rightTreeData);
  1535. }else if(this.rightTreeData1.length>0&&this.templateType===1&&this.rightObj1.wbsId==WbsId){
  1536. this.$refs.treetotree.setRightTree(this.rightTreeData1);
  1537. }else if(this.rightTreeData2.length>0&&this.templateType===5&&this.rightObj2.wbsId==WbsId){
  1538. this.$refs.treetotree.setRightTree(this.rightTreeData2);
  1539. }
  1540. else{
  1541. if (Array.isArray(res.data.data)) {
  1542. if(res.data.data.length>0){
  1543. this.iswbsselected=true
  1544. }else{
  1545. this.iswbsselected=false
  1546. }
  1547. console.log(11111111111);
  1548. this.$refs.treetotree.setRightTree(res.data.data);
  1549. } else {
  1550. this.$refs.treetotree.setRightTree([]);
  1551. this.iswbsselected=false
  1552. }
  1553. }
  1554. })
  1555. }
  1556. }
  1557. this.rightloading = false;
  1558. },
  1559. }
  1560. };
  1561. </script>
  1562. <style scoped lang="scss">
  1563. </style>