list.vue 78 KB

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