list.vue 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true">
  6. <el-form-item label="项目列表">
  7. </el-form-item>
  8. <el-form-item >
  9. <div>
  10. <el-input style="float:left;" v-model="keyword" class="input-with-select" placeholder="请输入项目名称关键字" clearable="true">
  11. <el-select v-model="searchField" style="width:120px;" slot="prepend" placeholder="请选择">
  12. <el-option label="项目名称" value=1 ></el-option>
  13. <el-option label="项目编码" value=2></el-option>
  14. </el-select>
  15. <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
  16. </el-input>
  17. </div>
  18. </el-form-item>
  19. <el-form-item v-if="user.company.packageProject==1">
  20. <span style="margin-left:10px;margin-right:10px;color:#606266;">状态</span>
  21. <el-select v-model="status" style="width:120px;" placeholder="请选择" @change="searchList">
  22. <el-option label="全部" value=0 ></el-option>
  23. <el-option label="进行中" value=1 ></el-option>
  24. <el-option label="已完成" value=2 ></el-option>
  25. <el-option label="已撤销" value=3 ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <!-- 项目成本基线条目 -->
  29. <el-form-item style="float:right;" v-if="user.role == 1||user.role == 2||user.role == 5">
  30. <el-link type="primary" :underline="false" @click="showBaseCostItemDialog">基线成本项</el-link>
  31. </el-form-item>
  32. <el-form-item style="float:right;" v-if="user.role == 1||user.role == 2||user.role == 5">
  33. <el-link type="primary" style="margin-left:5px;" :underline="false" href="./upload/项目导入模板.xlsx" download="项目导入模板.xlsx">模板下载</el-link>
  34. </el-form-item>
  35. <el-form-item style="float:right;" v-if="user.role == 1||user.role == 2||user.role == 5">
  36. <el-upload ref="upload" style="margin-left:5px;" action="#" :limit="1" :http-request="importProject" :show-file-list="false">
  37. <el-link type="primary" :underline="false" >导入项目</el-link>
  38. </el-upload>
  39. </el-form-item>
  40. <el-form-item style="float:right;" v-if="user.role == 1||user.role == 2||user.role == 5">
  41. <el-link type="primary" :underline="false" @click="handleAdd(-1,null)">新增项目</el-link>
  42. </el-form-item>
  43. <el-form-item style="float:right;" v-if="user.company.packageProject==1">
  44. <router-link to="/projectGantt" >
  45. <el-link type="primary" :underline="false" >甘特图</el-link>
  46. </router-link>
  47. </el-form-item>
  48. </el-form>
  49. </el-col>
  50. <!--列表-->
  51. <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  52. <el-table-column type="index" width="60">
  53. <template slot-scope="scope" >
  54. {{scope.$index+1+(page-1)*size}}
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="projectCode" label="项目编码" sortable width="150"></el-table-column>
  58. <el-table-column prop="projectName" label="项目名称" sortable>
  59. <template slot-scope="scope">
  60. <el-link type="primary" v-if="user.company.packageProject==1" :href="'#/projectInside/'+scope.row.id">{{scope.row.projectName}}</el-link>
  61. <span v-if="user.company.packageProject==0" >{{scope.row.projectName}}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="inchargerName" label="负责人" sortable width="150">
  65. <template slot-scope="scope">
  66. <el-link type="primary" @click="showUser(scope.row.inchargerId)">{{scope.row.inchargerName}}</el-link>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="participator" label="参与者" sortable v-if="user.company.packageProject==0">
  70. <template slot-scope="scope">
  71. <v-for v-for="par in scope.row.participator" :key="par.id" >
  72. <el-link style="margin-right:10px;" type="primary" @click="showUser(par.id)">{{par.name}}</el-link>
  73. </v-for>
  74. </template>
  75. </el-table-column>
  76. <!-- 客户管理 -->
  77. <el-table-column prop="customerName" label="客户" v-if="user.company.packageCustomer == 1">
  78. </el-table-column>
  79. <!--专业项目协作-->
  80. <el-table-column prop="status" label="状态" width="100" v-if="user.company.packageProject == 1">
  81. <template slot-scope="scope">
  82. {{scope.row.status == null?"-":statusTxt[scope.row.status]}}
  83. </template>
  84. </el-table-column>
  85. <el-table-column prop="progress" label="完成度" width="100" v-if="user.company.packageProject == 1">
  86. <template slot-scope="scope">
  87. {{scope.row.progress==null?"-":scope.row.progress}}%
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="操作" width="290" v-if="user.role == 1||user.role == 2||user.role == 5 || user.leader">
  91. <template slot-scope="scope">
  92. <el-button v-if="user.role>0" size="mini" @click="subProject(scope.row)">子项目</el-button>
  93. <el-button size="mini" v-if="user.role>0 || user.id==scope.row.inchargerId" type="primary" @click="handleAdd(scope.$index, scope.row)">编辑</el-button>
  94. <el-button v-if="user.role>0" size="mini" @click="deletePro(scope.$index, scope.row)">删除</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <!--工具条-->
  99. <el-col :span="24" class="toolbar">
  100. <el-pagination
  101. @size-change="handleSizeChange"
  102. @current-change="handleCurrentChange"
  103. :page-sizes="[20 , 50 , 80 , 100]"
  104. :page-size="20"
  105. layout="total, sizes, prev, pager, next"
  106. :total="total"
  107. style="float:right;"
  108. ></el-pagination>
  109. </el-col>
  110. <!--新增界面-->
  111. <el-dialog :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="960px">
  112. <el-form ref="form1" :model="addForm" :rules="rules" label-width="120px">
  113. <el-form-item label="项目编号" >
  114. <el-input v-model="addForm.code" :disabled="user.role==0" placeholder="请输入项目编号" clearable></el-input>
  115. </el-form-item>
  116. <el-form-item label="项目名称" prop="name">
  117. <el-input v-model="addForm.name" :disabled="user.role==0" placeholder="请输入项目名称" clearable></el-input>
  118. </el-form-item>
  119. <el-form-item label="项目类型" prop="isPublic">
  120. <el-select v-model="addForm.isPublic" style="width:32%;" @change="selectPublic">
  121. <el-option :value="0" label="普通项目"></el-option>
  122. <el-option :value="1" label="公共项目"></el-option>
  123. </el-select>
  124. <el-tooltip effect="dark" content="普通项目只对参与人员开放,公共项目对所有成员开放" placement="top-start">
  125. <i class="el-icon-question"></i>
  126. </el-tooltip>
  127. <span style="margin-left:63px;margin-right:10px;" v-if="user.company.packageCustomer == 1">客户</span>
  128. <el-select v-model="addForm.customerId" clearable="true" filterable placeholder="请选择客户" style="width:33%;" >
  129. <el-option v-for="item in customerList" :key="item.id" :label="item.customerName" :value="item.id"></el-option>
  130. </el-select>
  131. </el-form-item>
  132. <!-- <el-form-item label="客户" v-if="user.company.packageCustomer == 1">
  133. <el-select v-model="addForm.customerId" clearable="true" filterable placeholder="请选择客户" style="width:100%;" >
  134. <el-option v-for="item in customerList" :key="item.id" :label="item.customerName" :value="item.id"></el-option>
  135. </el-select>
  136. </el-form-item> -->
  137. <el-form-item label="全部参与者" v-show="addForm.isPublic == 0">
  138. <el-input @focus="showChooseMembTree" v-model="addForm.userNames"></el-input>
  139. </el-form-item>
  140. <el-form-item label="负责人" >
  141. <el-select v-model="addForm.inchargerId" :disabled="(addForm.userId.length==0 || user.role==0) && addForm.isPublic == 0" filterable placeholder="请选择负责人" style="width:100%;" >
  142. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id"></el-option>
  143. </el-select>
  144. </el-form-item>
  145. <!--专业项目协作版本功能 -->
  146. <el-form-item label="级别" v-if="user.company.packageProject==1">
  147. <el-select v-model="addForm.level" placeholder="请选择级别" style="width:32%;" >
  148. <el-option v-for="item in importanceList" :key="item.id" :label="item.label" :value="item.id"></el-option>
  149. </el-select>
  150. <!-- 增加合同金额字段 -->
  151. <span style="margin-left:63px;margin-right:10px;" v-if="user.company.packageProject==1">合同金额</span>
  152. <el-input id="contractAmount" v-model="addForm.contractAmount" style="width:33%;"
  153. placeholder="整数" clearable @keyup.native="restrictNumber('contractAmount')" ></el-input><span style="margin-left:10px;">元</span>
  154. <!-- 增加合同金额字段 -->
  155. </el-form-item>
  156. <el-form-item label="开始日期" prop="planStartDate" v-if="user.company.packageProject==1" >
  157. <el-date-picker v-model="addForm.planStartDate"
  158. :editable="false" style="width:32%;"
  159. format="yyyy-MM-dd"
  160. value-format="yyyy-MM-dd"
  161. :clearable="false" type="date"
  162. placeholder="选择日期"></el-date-picker>
  163. <span style="margin-left:63px;margin-right:10px;" >截止日期</span>
  164. <el-date-picker v-model="addForm.planEndDate" style="width:33%;"
  165. :editable="false"
  166. format="yyyy-MM-dd"
  167. value-format="yyyy-MM-dd"
  168. :clearable="false" type="date"
  169. placeholder="选择日期"></el-date-picker>
  170. </el-form-item>
  171. <!-- 项目基线 -->
  172. <div style="margin: 10px 0 30px 0;min-height:200px;" >
  173. <el-tabs v-model="activeName" @tab-click="handleClick">
  174. <el-tab-pane label="成本基线" name="baseCostPanel" >
  175. <div style="padding-top:10px;">
  176. <!--新版 -->
  177. <span class="rg_span" v-for="(item, index) in projectBaseCostData" :key="item.id">
  178. <span style="width:120px;display: inline-block;" v-if="user.company.packageProject==1">{{item.baseName}}</span>
  179. <el-input :id="'baseCost'+index" @input="addUpfun()" v-model="item.baseAmount" style="width:200px; margin-bottom: 20px"
  180. placeholder="整数" clearable @keyup.native="restrictNumber('baseCost'+index)"></el-input><span style="margin-left:10px;">元</span>
  181. </span>
  182. <!-- 合计 -->
  183. <div style="margin-top: 10px;float:right;">
  184. <span style="margin-right:50px;margin-right:10px;" v-if="user.company.packageProject==1">合计</span>
  185. <span v-if="addForm.budget <= 0 || addForm.budget == undefined">0</span>
  186. <span v-else>{{addForm.budget | numberToCurrency}}</span>
  187. <span style="margin-right:50px;margin-left:10px;">元</span>
  188. </div>
  189. </div>
  190. </el-tab-pane>
  191. <el-tab-pane label="工程专业" name="engineeringProfession" v-if="user.company.packageEngineering == 1">
  192. <div style="padding-top:10px;">
  193. <el-table :data="projectProfessionList" size="small" :key="Math.random()">
  194. <el-table-column prop="professionId" width="200">
  195. <template slot-scope="scope">
  196. <el-select v-model="scope.row.professionId" >
  197. <el-option v-for="item in professionList" :key="item.id" :label="item.name" :value="item.id"/>
  198. </el-select>
  199. </template>
  200. <template slot="header" >
  201. <span style="font-size:14px;font-weight:normal;">专业名称</span>
  202. </template>
  203. </el-table-column>
  204. <el-table-column prop="percentage" width="120" label="占比(%)">
  205. <template slot-scope="scope">
  206. <div><el-input type="number" v-model="scope.row.percentage"></el-input></div>
  207. </template>
  208. </el-table-column>
  209. <el-table-column prop="membNames" label="相关人员及占比">
  210. <template slot-scope="scope">
  211. <span style="margin:0 5px;" v-for="item in scope.row.membList" :key="item.membId">{{item.membName}}({{item.percentage}}%)</span>
  212. <el-link @click="showEditPpMembs(scope.row)">{{(scope.row.membList == null || scope.row.membList.length == 0)?'设置专业参与人员':'设置'}}</el-link>
  213. </template>
  214. </el-table-column>
  215. <el-table-column prop="inchargerName" width="120" label="负责人">
  216. <template slot-scope="scope">
  217. <el-select v-model="scope.row.inchargerId" >
  218. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id">
  219. </el-option>
  220. </el-select>
  221. </template>
  222. </el-table-column>
  223. <el-table-column width="80">
  224. <template slot-scope="scope">
  225. <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteItem(scope.$index)"></el-button>
  226. </template>
  227. <template slot="header" >
  228. <el-link type="primary" :underline="false" @click="addItem">添加</el-link>
  229. </template>
  230. </el-table-column>
  231. </el-table>
  232. </div>
  233. </el-tab-pane>
  234. <el-tab-pane label="相关领导" name="leaders" >
  235. <div style="padding-top:10px;">
  236. <el-input @focus="showChooseLeaderTree" v-model="addForm.notifyUserNames" placeholder="请选择需要接收审核通知的相关领导"></el-input>
  237. </div>
  238. </el-tab-pane>
  239. </el-tabs>
  240. </div>
  241. </el-form>
  242. <div slot="footer" class="dialog-footer;">
  243. <el-button @click.native="addFormVisible = false">取消</el-button>
  244. <el-button type="primary" @click="submitInsert" :loading="addLoading">提交</el-button>
  245. </div>
  246. </el-dialog>
  247. <!--用户详细信息弹出框-->
  248. <el-dialog title="查看详情" v-if="userDetailVisible" :visible.sync="userDetailVisible" :close-on-click-modal="false" customClass="customWidth" width="400px">
  249. <div class="line"><span>姓名</span><span>{{userDetail.name}}</span></div>
  250. <div class="line"><span>手机号码</span><span>{{userDetail.phone}}</span></div>
  251. <div class="line"><span>角色</span><span>{{roleArray[userDetail.role]}}</span></div>
  252. <div class="line"><span>部门</span><span>{{userDetail.departmentName}}</span></div>
  253. <div class="line" v-if="user.role>0&&user.role<=3"><span>成本</span><span>{{userDetail.cost}}元/小时</span></div>
  254. <div slot="footer" class="dialog-footer">
  255. <el-button type="primary" @click="userDetailVisible = false" >确定</el-button>
  256. </div>
  257. </el-dialog>
  258. <!-- 子项目列表 -->
  259. <el-dialog title="子项目列表" show-header="false" v-if="subProjectVisible" :visible.sync="subProjectVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  260. <el-table :data="subProjectList" highlight-current-row height="400" style="width: 100%;">
  261. <el-table-column type="index" width="60" label="序号">
  262. <template slot-scope="scope" >
  263. {{scope.$index+1+(page-1)*size}}
  264. </template>
  265. </el-table-column>
  266. <el-table-column prop="name" label="名称" ></el-table-column>
  267. <el-table-column label="操作" width="150">
  268. <template slot-scope="scope" >
  269. <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">编辑</el-button>
  270. <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">删除</el-button>
  271. </template>
  272. </el-table-column>
  273. </el-table>
  274. <div slot="footer" class="dialog-footer">
  275. <el-button type="primary" @click="subProjectVisible = false" >关闭</el-button>
  276. <el-button type="primary" @click="addNewSubProject()" >新增子项目</el-button>
  277. </div>
  278. </el-dialog>
  279. <!-- 新增子项目弹出框 -->
  280. <el-dialog title="新增/修改子项目" v-if="addSubProject" :visible.sync="addSubProject" :close-on-click-modal="false" customClass="customWidth" width="500px">
  281. <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
  282. <el-form-item label="项目名称" prop="name">
  283. <el-input v-model="addForm.name" placeholder="请输入项目名称" clearable></el-input>
  284. </el-form-item>
  285. </el-form>
  286. <div slot="footer" class="dialog-footer">
  287. <el-button @click.native="addSubProject = false">取消</el-button>
  288. <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">提交</el-button>
  289. </div>
  290. </el-dialog>
  291. <!-- 项目基线成本项配置弹出框 -->
  292. <el-dialog title="项目基线成本项管理" show-header="false" v-if="showBaseConfig" :visible.sync="showBaseConfig" :close-on-click-modal="false" customClass="customWidth" width="500px">
  293. <el-table :data="baseCostItemList" highlight-current-row height="400" style="width: 100%;">
  294. <el-table-column type="index" width="60" label="序号">
  295. <template slot-scope="scope" >
  296. {{scope.$index+1+(page-1)*size}}
  297. </template>
  298. </el-table-column>
  299. <el-table-column prop="name" label="名称" ></el-table-column>
  300. <el-table-column label="操作" width="150">
  301. <template slot-scope="scope" >
  302. <el-button size="small" type="primary" @click="addNewBaseItem(scope.row)">编辑</el-button>
  303. <el-button size="small" type="danger" @click="deleteBaseItem(scope.row)">删除</el-button>
  304. </template>
  305. </el-table-column>
  306. </el-table>
  307. <div slot="footer" class="dialog-footer">
  308. <el-button type="primary" @click="showBaseConfig = false" >关闭</el-button>
  309. <el-button type="primary" @click="addNewBaseItem()" >新增成本项</el-button>
  310. </div>
  311. </el-dialog>
  312. <el-dialog title="新增/修改成本项" v-if="addBaseItemDialog" :visible.sync="addBaseItemDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  313. <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
  314. <el-form-item label="成本项名称" prop="name">
  315. <el-input v-model="addForm.name" placeholder="请输入名称" clearable></el-input>
  316. </el-form-item>
  317. </el-form>
  318. <div slot="footer" class="dialog-footer">
  319. <el-button @click.native="addBaseItemDialog = false">取消</el-button>
  320. <el-button type="primary" @click="submitInsertBaseItem" :loading="addLoading">提交</el-button>
  321. </div>
  322. </el-dialog>
  323. <!-- 按部门选择人员 -->
  324. <el-dialog title="选择参与人员" v-if="chooseParticipVisible" :visible.sync="chooseParticipVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  325. <!-- <el-input style="width:100%" v-model="filterName" placeholder="请输入姓名搜索" @change="findUserInTree"></el-input> -->
  326. <div class="tree" style="height:400px">
  327. <el-scrollbar style="height:100%">
  328. <el-tree :data="deptMembData" show-checkbox :props="defaultProps" node-key="id"
  329. ref="chooseMembTree" @check-change="onTreeItemChange" :default-checked-keys="addForm.userId"
  330. highlight-current ></el-tree>
  331. </el-scrollbar>
  332. </div>
  333. <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>
  334. <div slot="footer" class="dialog-footer">
  335. <el-button @click="chooseParticipVisible = false" >取消</el-button>
  336. <el-button type="primary" @click="chooseParticip()" >确定</el-button>
  337. </div>
  338. </el-dialog>
  339. <!-- 按部门选择相关领导 -->
  340. <el-dialog title="选择相关领导" v-if="chooseLeaderVisible" :visible.sync="chooseLeaderVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  341. <!-- <el-input style="width:100%" v-model="filterName" placeholder="请输入姓名搜索" @change="findUserInTree"></el-input> -->
  342. <div class="tree" style="height:400px">
  343. <el-scrollbar style="height:100%">
  344. <el-tree :data="deptMembData" show-checkbox :props="defaultProps" node-key="id"
  345. ref="chooseLeaderTree" @check-change="onLeaderTreeItemChange" :default-checked-keys="addForm.notifyUserIds"
  346. highlight-current ></el-tree>
  347. </el-scrollbar>
  348. </div>
  349. <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>
  350. <div slot="footer" class="dialog-footer">
  351. <el-button @click="chooseLeaderVisible = false" >取消</el-button>
  352. <el-button type="primary" @click="chooseLeader()" >确定</el-button>
  353. </div>
  354. </el-dialog>
  355. <!-- 项目专业人员的设置 -->
  356. <el-dialog title="设置项目专业人员" v-if="editPpMembDialog" :visible.sync="editPpMembDialog" :close-on-click-modal="false" customClass="customWidth" width="600px">
  357. <el-table :data="curProfessionRow.membList" height="400">
  358. <el-table-column prop="name" label="专业人员">
  359. <template slot-scope="scope">
  360. <el-select v-model="scope.row.membId" filterable placeholder="请选择专业参与人" style="width:100%;" >
  361. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id">
  362. </el-option>
  363. </el-select>
  364. </template>
  365. </el-table-column>
  366. <el-table-column prop="percentage" width="120" label="占比(%)">
  367. <template slot-scope="scope">
  368. <el-input type="number" v-model="scope.row.percentage"></el-input>
  369. </template>
  370. </el-table-column>
  371. <el-table-column width="80">
  372. <template slot-scope="scope">
  373. <el-button icon="el-icon-delete" size="mini" style="margin-left:10px;" @click.stop.native="deleteMembItem(scope.$index)"></el-button>
  374. </template>
  375. <template slot="header" >
  376. <el-link @click="addMembItem">添加</el-link>
  377. </template>
  378. </el-table-column>
  379. </el-table>
  380. <div slot="footer" class="dialog-footer">
  381. <el-button @click="editPpMembDialog = false" >取消</el-button>
  382. <el-button type="primary" @click="addPpMemb" >确定</el-button>
  383. </div>
  384. </el-dialog>
  385. </section>
  386. </template>
  387. <style scoped>
  388. .input-with-select .el-input-group__prepend {
  389. background-color: #fff;
  390. }
  391. .line {
  392. padding:10px;
  393. }
  394. .line span{
  395. font-size:15px;
  396. }
  397. .line span:nth-child(even){
  398. float:right;
  399. }
  400. </style>
  401. <script>
  402. import util from "../../common/js/util";
  403. export default {
  404. data() {
  405. return {
  406. chosenLeaders:[],
  407. chooseLeaderVisible:false,
  408. projectProfessionItem:null,
  409. curProfessionRow:null,
  410. editPpMembDialog:false,
  411. professionList:[],
  412. projectProfessionList:[],
  413. activeName:"baseCostPanel",
  414. chosenMembCount:0,
  415. chosenMembList:[],//选中的人员
  416. allMembData:[],
  417. deptMembData: [
  418. {
  419. id: 0,
  420. label: '未分配',
  421. }
  422. ],
  423. option: [],
  424. depData: {
  425. id: -1,
  426. label: '全部人员',
  427. },
  428. defaultProps: {
  429. children: 'children',
  430. label: 'label'
  431. },
  432. filterName:null,
  433. chooseParticipVisible: false,
  434. projectBaseCostData:[],
  435. addBaseItemDialog:false,
  436. showBaseConfig:false,
  437. customerList:[],
  438. roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","人事管理员", "项目管理员"],
  439. status:null,
  440. statusTxt:["-","进行中","已完成","已撤销"],
  441. importanceList:[{id:1,label:'正常'},{id:2,label:'紧急'},{id:3,label:'重要'},{id:4,label:'重要且紧急'}],
  442. searchField:null,
  443. keyword:null,
  444. user: JSON.parse(sessionStorage.getItem("user")),
  445. userDetailVisible: false,
  446. userDetail:{},
  447. date: new Date(),
  448. users: [],
  449. participator:[],
  450. tableHeight: 0,
  451. listLoading: false,
  452. total: 0,
  453. page: 1,
  454. size: 20,
  455. list: [],
  456. subProjectVisible: false,
  457. subProjectList: [],//子项目列表
  458. currentProject:{},
  459. addSubProject: false,
  460. addFormVisible: false,
  461. addLoading: false,
  462. addUp: 0, // 合计
  463. title: "",
  464. addForm: {
  465. name: '',
  466. userId: [],
  467. level:1,
  468. },
  469. rules: {
  470. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  471. }
  472. };
  473. },
  474. // 过滤器
  475. filters: {
  476. numberToCurrency(value) {
  477. if (!value) return '0.00'
  478. // 将数值截取,保留两位小数
  479. value = value.toFixed(2)
  480. // 获取整数部分
  481. const intPart = Math.trunc(value)
  482. // 整数部分处理,增加,
  483. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  484. // 预定义小数部分
  485. let floatPart = '.00'
  486. // 将数值截取为小数部分和整数部分
  487. const valueArray = value.toString().split('.')
  488. if (valueArray.length === 2) { // 有小数部分
  489. floatPart = valueArray[1].toString() // 取得小数部分
  490. return intPartFormat + '.' + floatPart
  491. }
  492. return intPartFormat + floatPart
  493. }
  494. },
  495. methods: {
  496. selectPublic() {
  497. if (this.addForm.isPublic == 1) {
  498. this.participator = this.users;
  499. } else {
  500. this.participator = [];
  501. }
  502. },
  503. addPpMemb() {
  504. //检查合计比例是否到达100%
  505. let p = 0;
  506. let hasNoMemb = false;
  507. this.curProfessionRow.membList.forEach(m=>{
  508. p += parseInt(m.percentage);
  509. //检查人员是否选择
  510. if (m.membId == null) {
  511. hasNoMemb = true;
  512. }
  513. });
  514. if (hasNoMemb) {
  515. this.$message({
  516. message: '专业人员不能为空',
  517. type: "error"
  518. });
  519. return;
  520. }
  521. //检查人员不能重复
  522. let hasDuplicate = false;
  523. this.curProfessionRow.membList.forEach(m=>{
  524. if (this.curProfessionRow.membList.filter(innerM=>innerM.membId == m.membId).length>1) {
  525. hasDuplicate = true;
  526. }
  527. });
  528. if (hasDuplicate) {
  529. this.$message({
  530. message: '专业人员不能重复',
  531. type: "error"
  532. });
  533. return;
  534. }
  535. if (p != 100) {
  536. this.$message({
  537. message: '占比合计必须是100%',
  538. type: "error"
  539. });
  540. return;
  541. }
  542. this.editPpMembDialog = false;
  543. this.curProfessionRow.membList.forEach(m=>{
  544. m.membName = this.participator.filter(p=>p.id == m.membId)[0].name;
  545. });
  546. this.projectProfessionItem.membList = JSON.parse(JSON.stringify(this.curProfessionRow.membList));
  547. },
  548. //删除专业人员
  549. deleteMembItem(index) {
  550. this.curProfessionRow.membList.splice(index,1);
  551. },
  552. //添加专业人员
  553. addMembItem() {
  554. if (this.curProfessionRow.membList == null) {
  555. this.curProfessionRow.membList = [{membId:null, percentage:100}];
  556. } else {
  557. let p = 0;
  558. this.curProfessionRow.membList.forEach(m=>{
  559. p += parseInt(m.percentage);
  560. });
  561. this.curProfessionRow.membList.push({membId:null, percentage:100-p});
  562. }
  563. this.$forceUpdate();
  564. },
  565. showEditPpMembs(row) {
  566. this.projectProfessionItem = row;
  567. this.curProfessionRow = JSON.parse(JSON.stringify(row));
  568. if (this.curProfessionRow.membList == null || this.curProfessionRow.membList.length == 0) {
  569. this.curProfessionRow.membList = [{membId:null, percentage:100}];
  570. }
  571. this.editPpMembDialog = true;
  572. },
  573. getProjectNotifyUserList(projectId) {
  574. this.http.post("/project-notify-user/get", {projectId: projectId},
  575. res => {
  576. if (res.code == "ok") {
  577. var chosenLeaderIds = [];
  578. var chosenLeaderNames = '';
  579. var leaderList = res.data;
  580. this.chosenLeaders = leaderList;
  581. for(var j in leaderList) {
  582. chosenLeaderIds.push(leaderList[j].userId)
  583. chosenLeaderNames += leaderList[j].userName+',';
  584. }
  585. if (chosenLeaderNames.length > 0) {
  586. chosenLeaderNames = chosenLeaderNames.substring(0, chosenLeaderNames.length -1);
  587. }
  588. this.addForm.notifyUserIds = chosenLeaderIds;
  589. this.addForm.notifyUserNames = chosenLeaderNames;
  590. } else {
  591. this.$message({
  592. message: res.msg,
  593. type: "error"
  594. });
  595. }
  596. },
  597. error => {
  598. this.$message({
  599. message: error,
  600. type: "error"
  601. });
  602. });
  603. },
  604. getProjectProfessions(projectId) {
  605. this.http.post("/project-profession/get", {projectId: projectId},
  606. res => {
  607. if (res.code == "ok") {
  608. this.projectProfessionList = res.data;
  609. } else {
  610. this.$message({
  611. message: res.msg,
  612. type: "error"
  613. });
  614. }
  615. },
  616. error => {
  617. this.$message({
  618. message: error,
  619. type: "error"
  620. });
  621. });
  622. },
  623. checkProjectProfession() {
  624. //检查合计比例是否到达100%
  625. let p = 0;
  626. let hasNoMemb = false;
  627. let hasNoProfession = false;
  628. let hasNoMembList = false;
  629. this.projectProfessionList.forEach(m=>{
  630. p += parseInt(m.percentage);
  631. //检查人员是否选择
  632. if (m.inchargerId == null) {
  633. hasNoMemb = true;
  634. }
  635. if (m.professionId == null) {
  636. hasNoProfession = true;
  637. }
  638. if (m.membList == null) {
  639. hasNoMembList = true;
  640. }
  641. });
  642. if (hasNoProfession) {
  643. this.$message({
  644. message: '专业不能为空',
  645. type: "error"
  646. });
  647. return false;
  648. }
  649. if (hasNoMembList) {
  650. this.$message({
  651. message: '专业相关人员不能为空',
  652. type: "error"
  653. });
  654. return false;
  655. }
  656. if (hasNoMemb) {
  657. this.$message({
  658. message: '专业负责人不能为空',
  659. type: "error"
  660. });
  661. return false;
  662. }
  663. //检查专业不能重复
  664. let hasDuplicate = false;
  665. this.projectProfessionList.forEach(m=>{
  666. if (this.projectProfessionList.filter(innerM=>innerM.professionId == m.professionId).length>1) {
  667. hasDuplicate = true;
  668. }
  669. });
  670. if (hasDuplicate) {
  671. this.$message({
  672. message: '专业不能重复',
  673. type: "error"
  674. });
  675. return false;
  676. }
  677. if (this.projectProfessionList.length > 0 && p != 100) {
  678. this.$message({
  679. message: '专业占比合计必须是100%',
  680. type: "error"
  681. });
  682. return false;
  683. }
  684. return true;
  685. },
  686. //保存项目专业
  687. saveProjectProfessions(projectId) {
  688. var list = this.projectProfessionList.filter(p=>p.professionId != null);
  689. list.forEach(p=>p.inchargerName = this.participator.filter(m=>m.id == p.inchargerId)[0].name);
  690. list.forEach(p=>p.professionName = this.professionList.filter(m=>m.id == p.professionId)[0].name);
  691. this.http.post("/project-profession/modify", {projectId: projectId, json: JSON.stringify(list)},
  692. res => {
  693. if (res.code == "ok") {
  694. return false;
  695. } else {
  696. this.$message({
  697. message: res.msg,
  698. type: "error"
  699. });
  700. }
  701. },
  702. error => {
  703. this.$message({
  704. message: error,
  705. type: "error"
  706. });
  707. });
  708. },
  709. //删除项目专业
  710. deleteItem(index) {
  711. this.projectProfessionList.splice(index,1);
  712. },
  713. //添加项目专业
  714. addItem() {
  715. let p = 0;
  716. this.projectProfessionList.forEach(m=>{
  717. p += parseInt(m.percentage);
  718. });
  719. this.projectProfessionList.push( { professionId:null, inchargerId:null,membIds:[], percentage: 100-p});
  720. },
  721. getProfessionList() {
  722. this.http.post("/profession/getAll", {},
  723. res => {
  724. if (res.code == "ok") {
  725. var list = res.data;
  726. this.professionList = list;
  727. } else {
  728. this.$message({
  729. message: res.msg,
  730. type: "error"
  731. });
  732. }
  733. },
  734. error => {
  735. this.$message({
  736. message: error,
  737. type: "error"
  738. });
  739. });
  740. },
  741. restrictNumber(targetId) {
  742. let inpu = document.getElementById(targetId);
  743. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  744. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  745. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  746. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  747. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  748. inpu.value = parseFloat(inpu.value);
  749. }
  750. },
  751. showChooseLeaderTree() {
  752. this.chosenMembCount = this.chosenLeaders.length;
  753. this.chooseLeaderVisible = true;
  754. },
  755. onLeaderTreeItemChange() {
  756. var chosenList = this.$refs.chooseLeaderTree.getCheckedNodes();
  757. var list = chosenList.filter(item=>item.isUser == 1);
  758. this.chosenMembCount = list.length;
  759. },
  760. showChooseMembTree() {
  761. this.chosenMembCount = this.participator.length;
  762. this.chooseParticipVisible = true;
  763. },
  764. onTreeItemChange() {
  765. var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
  766. var list = chosenList.filter(item=>item.isUser == 1);
  767. this.chosenMembCount = list.length;
  768. },
  769. findUserInTree() {
  770. if (this.filterName == '') {
  771. this.deptMembData = this.allMembData;
  772. } else {
  773. var list = this.findRecursively(this.filterName, this.allMembData);
  774. this.deptMembData = list;
  775. }
  776. },
  777. findRecursively(username, list) {
  778. var filterList = [];
  779. for (var i=0;i<list.length; i++) {
  780. if (list[i].isUser == 1) {
  781. if (list[i].label.indexOf(username) >= 0) {
  782. //匹配上了
  783. filterList.push(list[i]);
  784. }
  785. } else if (list[i].children != null && list[i].children.length > 0) {
  786. var subList = this.findRecursively(username, list[i].children);
  787. if (subList.length > 0) {
  788. subList.forEach(s=>filterList.push(s));
  789. }
  790. }
  791. }
  792. return filterList;
  793. },
  794. //确定选择参与人
  795. chooseParticip() {
  796. this.chooseParticipVisible = false;
  797. var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
  798. this.chosenMembList = chosenList.filter(item=>item.isUser == 1);
  799. this.addForm.userNames = '';
  800. this.addForm.userId = [];
  801. this.participator = [];
  802. for (var i=0;i<this.chosenMembList.length; i++) {
  803. this.addForm.userId.push(this.chosenMembList[i].id);
  804. this.addForm.userNames += this.chosenMembList[i].label+',';
  805. var item = {id:this.chosenMembList[i].id, name:this.chosenMembList[i].label};
  806. this.participator.push(item);
  807. }
  808. if (this.addForm.userNames.length > 0) {
  809. this.addForm.userNames = this.addForm.userNames.substring(0, this.addForm.userNames.length-1);
  810. }
  811. },
  812. //选中相关领导
  813. chooseLeader() {
  814. this.chooseLeaderVisible = false;
  815. var chosenList = this.$refs.chooseLeaderTree.getCheckedNodes();
  816. var chosenMembList = chosenList.filter(item=>item.isUser == 1);
  817. this.addForm.notifyUserNames = '';
  818. this.addForm.notifyUserIds = [];
  819. this.chosenLeaders = [];
  820. for (var i=0;i<chosenMembList.length; i++) {
  821. this.addForm.notifyUserIds.push(chosenMembList[i].id);
  822. this.addForm.notifyUserNames += chosenMembList[i].label+',';
  823. var item = {userId:chosenMembList[i].id, userName:chosenMembList[i].label};
  824. this.chosenLeaders.push(item);
  825. }
  826. if (this.addForm.notifyUserNames.length > 0) {
  827. this.addForm.notifyUserNames = this.addForm.notifyUserNames.substring(0, this.addForm.notifyUserNames.length-1);
  828. }
  829. },
  830. // 获取部门列表
  831. getDepartment() {
  832. this.http.post("/department/listAllMemb", {},
  833. res => {
  834. if (res.code == "ok") {
  835. var list = res.data;
  836. //设置员工到部门下面
  837. this.setUserToDept(list);
  838. this.deptMembData = list;
  839. //用于筛选过滤
  840. this.allMembData = JSON.parse(JSON.stringify(this.deptMembData));
  841. } else {
  842. this.$message({
  843. message: res.msg,
  844. type: "error"
  845. });
  846. }
  847. },
  848. error => {
  849. this.$message({
  850. message: error,
  851. type: "error"
  852. });
  853. });
  854. },
  855. setUserToDept(list) {
  856. for (var i in list) {
  857. if (list[i].children != null) {
  858. this.setUserToDept(list[i].children);
  859. }
  860. if (list[i].userList != null) {
  861. if (list[i].children == null) {
  862. list[i].children = [];
  863. }
  864. list[i].userList.forEach(element => {
  865. var obj = {id: element.id, label:element.name, parentId:element.departmentId, isUser:1};
  866. list[i].children.push(obj);
  867. });
  868. }
  869. }
  870. },
  871. getProjectBaseConfigList() {
  872. this.http.post('/project-basecost-setting/list',{},
  873. res => {
  874. if (res.code == "ok") {
  875. this.baseCostItemList = res.data;
  876. this.$forceUpdate();
  877. } else {
  878. this.$message({
  879. message: res.msg,
  880. type: "error"
  881. });
  882. }
  883. },
  884. error => {
  885. this.$message({
  886. message: error,
  887. type: "error"
  888. });
  889. }
  890. );
  891. },
  892. deleteBaseItem(row) {
  893. this.$confirm("该操作可能造成已有数据丢失,确定要删除吗?","删除成本基线项", {
  894. confirmButtonText: "确定",
  895. cancelButtonText: "取消",
  896. type: "warning"
  897. })
  898. .then(() => {
  899. this.listLoading = true;
  900. this.http.post('/project-basecost-setting/delete',{
  901. id: row.id
  902. },
  903. res => {
  904. this.listLoading = false;
  905. if (res.code == "ok") {
  906. this.$message({
  907. message: "删除成功",
  908. type: "success"
  909. });
  910. this.getProjectBaseConfigList();
  911. } else {
  912. this.$message({
  913. message: res.msg,
  914. type: "error"
  915. });
  916. }
  917. },
  918. error => {
  919. this.listLoading = false;
  920. this.$message({
  921. message: error,
  922. type: "error"
  923. });
  924. }
  925. );
  926. })
  927. .catch(() => {});
  928. },
  929. submitInsertBaseItem() {
  930. this.http.post('/project-basecost-setting/addOrMod',this.addForm,
  931. res => {
  932. if (res.code == "ok") {
  933. this.addBaseItemDialog = false;
  934. this.baseCostItemList = res.data;
  935. this.$forceUpdate();
  936. } else {
  937. this.$message({
  938. message: res.msg,
  939. type: "error"
  940. });
  941. }
  942. },
  943. error => {
  944. this.$message({
  945. message: error,
  946. type: "error"
  947. });
  948. }
  949. );
  950. },
  951. showBaseCostItemDialog() {
  952. this.showBaseConfig = true;
  953. },
  954. addNewBaseItem(row) {
  955. this.addBaseItemDialog = true;
  956. if (row == null) {
  957. this.addForm = {}
  958. } else {
  959. this.addForm = row;
  960. }
  961. },
  962. //获取客户列表
  963. getCustomerList() {
  964. this.http.post('/customer-info/getAll', {
  965. },
  966. res => {
  967. if (res.code == "ok") {
  968. this.customerList = res.data;
  969. } else {
  970. this.$message({
  971. message: res.msg,
  972. type: "error"
  973. });
  974. }
  975. },
  976. error => {
  977. this.$message({
  978. message: error,
  979. type: "error"
  980. });
  981. });
  982. },
  983. importProject(item) {
  984. //首先判断文件类型
  985. let str = item.file.name.split(".");
  986. let format = str[str.length - 1];
  987. if (format != "xls" && format != "xlsx") {
  988. this.$message({
  989. message: "请选择.xls或.xlsx文件",
  990. type: "error"
  991. });
  992. } else {
  993. this.listLoading = true;
  994. let formData = new FormData();
  995. formData.append("file", item.file);
  996. formData.append("userId", this.user.id);
  997. this.http.uploadFile('/project/importData', formData,
  998. res => {
  999. this.$refs.upload.clearFiles();
  1000. this.listLoading = false;
  1001. if (res.code == "ok") {
  1002. this.$message({
  1003. message: "导入成功",
  1004. type: "success"
  1005. });
  1006. this.getList();
  1007. } else {
  1008. this.$message({
  1009. message: res.msg,
  1010. type: "error"
  1011. });
  1012. }
  1013. },
  1014. error => {
  1015. this.$refs.upload.clearFiles();
  1016. this.listLoading = false;
  1017. this.$message({
  1018. message: error,
  1019. type: "error"
  1020. });
  1021. });
  1022. }
  1023. },
  1024. number(){  
  1025. //     this.addForm.budget = this.addForm.budget.replace(/[^\.\d]/g,'');
  1026. // this.addForm.budget = this.addForm.budget.replace('.','');
  1027.   },
  1028. deleteSubPro(subProject) {
  1029. this.$confirm("确定要删除子项目" + subProject.name + "吗?","删除子项目", {
  1030. confirmButtonText: "确定",
  1031. cancelButtonText: "取消",
  1032. type: "warning"
  1033. })
  1034. .then(() => {
  1035. this.listLoading = true;
  1036. this.http.post('/sub-project/deleteProject',{
  1037. id: subProject.id
  1038. },
  1039. res => {
  1040. this.listLoading = false;
  1041. if (res.code == "ok") {
  1042. this.$message({
  1043. message: "删除成功",
  1044. type: "success"
  1045. });
  1046. this.subProject(this.currentProject);
  1047. } else {
  1048. this.$message({
  1049. message: res.msg,
  1050. type: "error"
  1051. });
  1052. }
  1053. },
  1054. error => {
  1055. this.listLoading = false;
  1056. this.$message({
  1057. message: error,
  1058. type: "error"
  1059. });
  1060. }
  1061. );
  1062. })
  1063. .catch(() => {});
  1064. },
  1065. searchList() {
  1066. this.page = 1;
  1067. this.getList();
  1068. },
  1069. addNewSubProject(subProject) {
  1070. console.log(123);
  1071. if (subProject == null) {
  1072. this.addForm = {projectId: this.currentProject.id, level:1}
  1073. } else {
  1074. this.addForm = subProject;
  1075. }
  1076. this.addSubProject = true;
  1077. },
  1078. //显示子项目
  1079. subProject(item) {
  1080. this.subProjectVisible = true;
  1081. this.currentProject = item;
  1082. this.http.post('/sub-project/list', {
  1083. projectId: item.id
  1084. },
  1085. res => {
  1086. if (res.code == "ok") {
  1087. this.subProjectList = res.data;
  1088. } else {
  1089. this.$message({
  1090. message: res.msg,
  1091. type: "error"
  1092. });
  1093. }
  1094. },
  1095. error => {
  1096. this.$message({
  1097. message: error,
  1098. type: "error"
  1099. });
  1100. });
  1101. },
  1102. //显示用户详情
  1103. showUser(userId) {
  1104. this.userDetailVisible = true;
  1105. this.http.post(this.port.manage.userDetail, {
  1106. userId: userId
  1107. },
  1108. res => {
  1109. if (res.code == "ok") {
  1110. this.userDetail = res.data;
  1111. } else {
  1112. this.$message({
  1113. message: res.msg,
  1114. type: "error"
  1115. });
  1116. }
  1117. },
  1118. error => {
  1119. this.$message({
  1120. message: error,
  1121. type: "error"
  1122. });
  1123. });
  1124. },
  1125. //选择参与人
  1126. changeParticipator() {
  1127. //检查是否在参与人中,如果没有需要加入到参与人中
  1128. this.participator = [];
  1129. this.addForm.userId.forEach(u=>{
  1130. var list = this.users.filter(au=>au.id == u);
  1131. if (list.length > 0) {
  1132. var findUser = list[0];
  1133. this.participator.push(findUser);
  1134. } else {
  1135. console.log('未找到用户: '+u);
  1136. }
  1137. })
  1138. },
  1139. getUsers() {
  1140. this.http.post(this.port.manage.list, {
  1141. departmentId: -1,
  1142. pageIndex: 1,
  1143. pageSize: 99999
  1144. },
  1145. res => {
  1146. if (res.code == "ok") {
  1147. this.users = res.data.records;
  1148. } else {
  1149. this.$message({
  1150. message: res.msg,
  1151. type: "error"
  1152. });
  1153. }
  1154. },
  1155. error => {
  1156. this.$message({
  1157. message: error,
  1158. type: "error"
  1159. });
  1160. });
  1161. },
  1162. //分页
  1163. handleCurrentChange(val) {
  1164. this.page = val;
  1165. this.getList();
  1166. },
  1167. handleSizeChange(val) {
  1168. this.size = val;
  1169. this.getList();
  1170. },
  1171. //获取项目列表
  1172. getList() {
  1173. this.listLoading = true;
  1174. this.http.post(this.port.project.listPage, {
  1175. pageIndex: this.page,
  1176. pageSize: this.size,
  1177. keyword:this.keyword,
  1178. searchField: this.searchField,
  1179. status: this.status
  1180. },
  1181. res => {
  1182. this.listLoading = false;
  1183. if (res.code == "ok") {
  1184. var list = res.data.records;
  1185. for(var i in list) {
  1186. var participator = list[i].participator , str = "";
  1187. for(var j in participator) {
  1188. if(j == participator.length-1) {
  1189. str += participator[j].name
  1190. } else {
  1191. str += participator[j].name + ','
  1192. }
  1193. }
  1194. list[i].userNames = str;
  1195. }
  1196. this.list = list;
  1197. this.total = res.data.total;
  1198. } else {
  1199. this.$message({
  1200. message: res.msg,
  1201. type: "error"
  1202. });
  1203. }
  1204. },
  1205. error => {
  1206. this.listLoading = false;
  1207. this.$message({
  1208. message: error,
  1209. type: "error"
  1210. });
  1211. });
  1212. },
  1213. //显示新增界面
  1214. handleAdd(i, item) {
  1215. if(i == -1) {
  1216. this.title = "新增项目";
  1217. this.addForm = {
  1218. name: '',
  1219. isPublic:0,
  1220. userId: [],
  1221. userNames:'',
  1222. code:'',
  1223. inchargerId:null,
  1224. level:1,
  1225. customerId:null,
  1226. notifyUserNames:'',
  1227. chosenLeaders:[],
  1228. }
  1229. this.projectBaseCostData = [];
  1230. for (var m=0;m<this.baseCostItemList.length; m++) {
  1231. this.projectBaseCostData.push({baseId: this.baseCostItemList[m].id, baseName:this.baseCostItemList[m].name, baseAmount:0});
  1232. }
  1233. } else {
  1234. this.title = "修改项目";
  1235. var list = item.participator;
  1236. if (item.isPublic == 1) {
  1237. list = this.users;
  1238. }
  1239. var arr = [];
  1240. var names = '';
  1241. for(var j in list) {
  1242. arr.push(list[j].id)
  1243. names += list[j].name+',';
  1244. }
  1245. if (names.length > 0) {
  1246. names = names.substring(0, names.length -1);
  1247. }
  1248. this.addForm = {
  1249. id: item.id,
  1250. name: item.projectName,
  1251. isPublic: item.isPublic,
  1252. userId: arr,
  1253. userNames:names,
  1254. code:item.projectCode,
  1255. inchargerId: item.inchargerId,
  1256. level: item.level,
  1257. planStartDate: item.planStartDate,
  1258. planEndDate: item.planEndDate,
  1259. budget: item.budget,
  1260. baseMan: item.baseMan,
  1261. contractAmount: item.contractAmount,
  1262. baseFee: item.baseFee,
  1263. baseRisk1: item.baseRisk1,
  1264. baseRisk2: item.baseRisk2,
  1265. baseOutsourcing: item.baseOutsourcing,
  1266. customerId:item.customerId==0?null:item.customerId,
  1267. }
  1268. this.changeParticipator();
  1269. this.getProjectBaseData(item.id);
  1270. if (this.user.company.packageEngineering == 1) {
  1271. this.getProjectProfessions(item.id);
  1272. }
  1273. //获取项目的相关领导
  1274. this.getProjectNotifyUserList(item.id);
  1275. }
  1276. this.addFormVisible = true;
  1277. if (this.user.company.packageEngineering == 1) {
  1278. if (this.professionList.length == 0) {
  1279. this.getProfessionList();
  1280. }
  1281. }
  1282. },
  1283. getProjectBaseData(projectId) {
  1284. this.http.post('/project-basecost/get',{projectId: projectId},
  1285. res => {
  1286. if (res.code == "ok") {
  1287. this.projectBaseCostData = res.data;
  1288. } else {
  1289. this.$message({
  1290. message: res.msg,
  1291. type: "error"
  1292. });
  1293. }
  1294. },
  1295. error => {
  1296. this.listLoading = false;
  1297. this.$message({
  1298. message: error,
  1299. type: "error"
  1300. });
  1301. }
  1302. );
  1303. },
  1304. //提交子项目创建修改请求
  1305. submitInsertSubProject () {
  1306. this.$refs.form2.validate(valid => {
  1307. if (valid) {
  1308. this.http.post('/sub-project/saveOrUpdate',this.addForm,
  1309. res => {
  1310. if (res.code == "ok") {
  1311. this.$message({
  1312. message: "操作成功",
  1313. type: "success"
  1314. });
  1315. this.subProject(this.currentProject);
  1316. this.addSubProject = false;
  1317. } else {
  1318. this.$message({
  1319. message: res.msg,
  1320. type: "error"
  1321. });
  1322. }
  1323. },
  1324. error => {
  1325. this.listLoading = false;
  1326. this.$message({
  1327. message: error,
  1328. type: "error"
  1329. });
  1330. }
  1331. );
  1332. }
  1333. });
  1334. },
  1335. // 项目基线合计
  1336. addUpfun() {
  1337. var total = 0;
  1338. for (var i=0;i<this.projectBaseCostData.length; i++) {
  1339. total += parseFloat(this.projectBaseCostData[i].baseAmount);
  1340. }
  1341. this.addForm.budget = total;
  1342. // var a = '0'
  1343. // var q = '0'
  1344. // var w = '0'
  1345. // var e = '0'
  1346. // var r = '0'
  1347. // // this.addForm.baseMan === undefined || this.addForm.baseMan === NaN ? this.addForm.baseMa = '0' : this.addForm.baseMan
  1348. // if (this.addForm.baseMan == undefined || this.addForm.baseMan == NaN) {
  1349. // a = 0
  1350. // } else {
  1351. // a = this.addForm.baseMan
  1352. // }
  1353. // if (this.addForm.baseFee !== undefined) q = this.addForm.baseFee
  1354. // if (this.addForm.baseOutsourcing !== undefined) w = this.addForm.baseOutsourcing
  1355. // if (this.addForm.baseRisk1 !== undefined) e = this.addForm.baseRisk1
  1356. // if (this.addForm.baseRisk2 !== undefined) r = this.addForm.baseRisk2
  1357. // this.addForm.budget = +a + +q + +w + +e + +r
  1358. },
  1359. submitInsert() {
  1360. this.$refs.form1.validate(valid => {
  1361. if (valid) {
  1362. if (this.user.company.packageEngineering == 1) {
  1363. if (!this.checkProjectProfession()) {//检查不通过,直接返回
  1364. return;
  1365. }
  1366. }
  1367. this.addLoading = true;
  1368. let formData = new FormData();
  1369. formData.append("name", this.addForm.name);
  1370. if(this.addForm.id != null) {
  1371. formData.append("id", this.addForm.id);
  1372. }
  1373. if(this.addForm.isPublic != null) {
  1374. formData.append("isPublic", this.addForm.isPublic);
  1375. }
  1376. if(this.addForm.userId.length != 0 && this.addForm.isPublic == 0) {
  1377. for(var j in this.addForm.userId) {
  1378. formData.append("userId", this.addForm.userId[j]);
  1379. }
  1380. }
  1381. if(this.addForm.inchargerId != null) {
  1382. formData.append("inchargerId", this.addForm.inchargerId);
  1383. }
  1384. if(this.addForm.code != null) {
  1385. formData.append("code", this.addForm.code);
  1386. }
  1387. if(this.addForm.planStartDate != null) {
  1388. formData.append("planStartDate", this.addForm.planStartDate);
  1389. }
  1390. if(this.addForm.planEndDate != null) {
  1391. formData.append("planEndDate", this.addForm.planEndDate);
  1392. }
  1393. if(this.addForm.level != null) {
  1394. formData.append("level", this.addForm.level);
  1395. }
  1396. if(this.addForm.contractAmount != null) {
  1397. formData.append("contractAmount", this.addForm.contractAmount);
  1398. }
  1399. if (this.projectBaseCostData != null) {
  1400. formData.append("projectBaseCostData", JSON.stringify(this.projectBaseCostData));
  1401. //计算总预算成本
  1402. if (this.addForm.budget == null) {
  1403. this.addForm.budget = 0;
  1404. }
  1405. formData.append("budget", this.addForm.budget);
  1406. }
  1407. if (this.addForm.customerId == null) {
  1408. formData.append("customerId", 0);
  1409. } else {
  1410. formData.append("customerId", this.addForm.customerId);
  1411. }
  1412. if (this.chosenLeaders != null && this.chosenLeaders.length > 0) {
  1413. formData.append("chosenLeaders", JSON.stringify(this.chosenLeaders));
  1414. }
  1415. this.http.uploadFile(this.port.project.add,formData,
  1416. res => {
  1417. this.addLoading = false;
  1418. if (res.code == "ok") {
  1419. this.$message({
  1420. message: (this.addForm.id!=null?'修改':'创建')+"成功",
  1421. type: "success"
  1422. });
  1423. this.addFormVisible = false;
  1424. this.getList();
  1425. if (this.user.company.packageEngineering == 1) {
  1426. this.saveProjectProfessions(res.data);
  1427. }
  1428. } else {
  1429. this.$message({
  1430. message: res.msg,
  1431. type: "error"
  1432. });
  1433. }
  1434. },
  1435. error => {
  1436. this.addLoading = false;
  1437. this.$message({
  1438. message: error,
  1439. type: "error"
  1440. });
  1441. });
  1442. }
  1443. });
  1444. },
  1445. // 删除
  1446. deletePro(i, item) {
  1447. this.$confirm("确定要项目" + item.projectName + "吗?","删除项目", {
  1448. confirmButtonText: "确定",
  1449. cancelButtonText: "取消",
  1450. type: "warning"
  1451. })
  1452. .then(() => {
  1453. this.listLoading = true;
  1454. this.http.post(this.port.project.delete,{
  1455. id: item.id
  1456. },
  1457. res => {
  1458. this.listLoading = false;
  1459. if (res.code == "ok") {
  1460. this.$message({
  1461. message: "删除成功",
  1462. type: "success"
  1463. });
  1464. this.getList();
  1465. } else {
  1466. this.$message({
  1467. message: res.msg,
  1468. type: "error"
  1469. });
  1470. }
  1471. },
  1472. error => {
  1473. this.listLoading = false;
  1474. this.$message({
  1475. message: error,
  1476. type: "error"
  1477. });
  1478. }
  1479. );
  1480. })
  1481. .catch(() => {});
  1482. },
  1483. detail(i) {
  1484. this.$router.push("/list/" + this.list[i].id + "/" + this.list[i].projectName);
  1485. }
  1486. },
  1487. created() {
  1488. let height = window.innerHeight;
  1489. this.tableHeight = height - 195;
  1490. const that = this;
  1491. window.onresize = function temp() {
  1492. that.tableHeight = window.innerHeight - 195;
  1493. };
  1494. },
  1495. mounted() {
  1496. this.getDepartment();
  1497. this.getList();
  1498. this.getUsers();
  1499. this.getCustomerList();
  1500. this.getProjectBaseConfigList();
  1501. }
  1502. };
  1503. </script>
  1504. <style lang="scss" scoped>
  1505. .rg_span{
  1506. display: inline-block;
  1507. }
  1508. .rg_span span {
  1509. text-align: right;
  1510. box-sizing: border-box;
  1511. padding-right: 10px;
  1512. }
  1513. .el-dialog__title {
  1514. display: inline-table;
  1515. margin-top: 20px;
  1516. }
  1517. </style>