list.vue 76 KB

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