list.vue 77 KB

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