list.vue 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  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="800px">
  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="客户" v-if="user.company.packageCustomer == 1">
  120. <el-select v-model="addForm.customerId" clearable="true" filterable placeholder="请选择客户" style="width:100%;" >
  121. <el-option v-for="item in customerList" :key="item.id" :label="item.customerName" :value="item.id"></el-option>
  122. </el-select>
  123. </el-form-item>
  124. <el-form-item label="全部参与者">
  125. <el-input @focus="showChooseMembTree" v-model="addForm.userNames"></el-input>
  126. <!-- <el-select v-model="addForm.userId" multiple filterable placeholder="请选择参与者" style="width:100%;" @change="changeParticipator">
  127. <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  128. </el-select> -->
  129. </el-form-item>
  130. <el-form-item label="负责人" >
  131. <el-select v-model="addForm.inchargerId" :disabled="addForm.userId.length==0 || user.role==0" filterable placeholder="请选择负责人" style="width:100%;" >
  132. <el-option v-for="item in participator" :key="item.id" :label="item.name" :value="item.id"></el-option>
  133. </el-select>
  134. </el-form-item>
  135. <!--专业项目协作版本功能 -->
  136. <el-form-item label="级别" v-if="user.company.packageProject==1">
  137. <el-select v-model="addForm.level" placeholder="请选择级别" style="width:32%;" >
  138. <el-option v-for="item in importanceList" :key="item.id" :label="item.label" :value="item.id"></el-option>
  139. </el-select>
  140. <!-- <span style="margin-left:50px;margin-right:10px;" v-if="user.company.packageProject==1">项目预算</span>
  141. <el-input v-model="addForm.budget" style="width:32%;"
  142. placeholder="整数" clearable @keyup.native="number"></el-input><span style="margin-left:10px;">元</span> -->
  143. <!-- 增加合同金额字段 -->
  144. <span style="margin-left:63px;margin-right:10px;" v-if="user.company.packageProject==1">合同金额</span>
  145. <el-input id="contractAmount" v-model="addForm.contractAmount" style="width:33%;"
  146. placeholder="整数" clearable @keyup.native="restrictNumber('contractAmount')" ></el-input><span style="margin-left:10px;">元</span>
  147. <!-- 增加合同金额字段 -->
  148. </el-form-item>
  149. <el-form-item label="开始日期" prop="planStartDate" v-if="user.company.packageProject==1" style="float: left" >
  150. <el-date-picker v-model="addForm.planStartDate"
  151. :editable="false"
  152. format="yyyy-MM-dd"
  153. value-format="yyyy-MM-dd"
  154. :clearable="false" type="date"
  155. placeholder="选择日期"></el-date-picker>
  156. </el-form-item>
  157. <el-form-item label="截止日期" prop="planEndDate" v-if="user.company.packageProject==1" style="float: left" >
  158. <el-date-picker v-model="addForm.planEndDate"
  159. :editable="false"
  160. format="yyyy-MM-dd"
  161. value-format="yyyy-MM-dd"
  162. :clearable="false" type="date"
  163. placeholder="选择日期"></el-date-picker>
  164. </el-form-item>
  165. <!-- 项目基线 -->
  166. <!-- <div style="width: 100%;border: 1px solid #ddd"></div> -->
  167. <div style="margin: 90px 0 30px 0" >
  168. <el-divider></el-divider>
  169. <span class="el-dialog__title">成本基线</span>
  170. </div>
  171. <!--新版 -->
  172. <span class="rg_span" v-for="(item, index) in projectBaseCostData" :key="item.id">
  173. <span style="width:120px;display: inline-block;" v-if="user.company.packageProject==1">{{item.baseName}}</span>
  174. <el-input :id="'baseCost'+index" @input="addUpfun()" v-model="item.baseAmount" style="width:200px; margin-bottom: 20px"
  175. placeholder="整数" clearable @keyup.native="restrictNumber('baseCost'+index)"></el-input><span style="margin-left:10px;">元</span>
  176. </span>
  177. <!-- <span class="rg_span">
  178. <span style="width:120px;display: inline-block;" v-if="user.company.packageProject==1">人工成本</span>
  179. <el-input @input="addUpfun(addForm.baseMan)" v-model="addForm.baseMan" style="width:200px; margin-bottom: 20px"
  180. placeholder="整数" clearable @keyup.native="addForm.baseMan=addForm.baseMan.replace(/[^\d]/g,'');"></el-input><span style="margin-left:10px;">元</span>
  181. </span>
  182. <span class="rg_span">
  183. <span style="width:120px;display: inline-block;" v-if="user.company.packageProject==1">费用</span>
  184. <el-input @input="addUpfun(addForm.baseFee)" v-model="addForm.baseFee" style="width:200px;"
  185. placeholder="整数" clearable @keyup.native="addForm.baseFee=addForm.baseFee.replace(/[^\d]/g,'');"></el-input><span style="margin-left:10px;">元</span>
  186. </span>
  187. <div class="rg_span" style="margin-bottom: 20px;">
  188. <span style=" width:120px;display: inline-block;" v-if="user.company.packageProject==1">外包费用</span>
  189. <el-input @input="addUpfun(addForm.baseOutsourcing)" v-model="addForm.baseOutsourcing" style="width:200px;"
  190. placeholder="整数" clearable @keyup.native="addForm.baseOutsourcing=addForm.baseOutsourcing.replace(/[^\d]/g,'');"></el-input><span style="margin-left:10px;">元</span>
  191. </div>
  192. <div style="display: inline-block;" class="rg_span">
  193. <span style="width:120px;display: inline-block;text-align: right;" v-if="user.company.packageProject==1">预留风险金额1</span>
  194. <el-input @input="addUpfun(addForm.baseRisk1)" v-model="addForm.baseRisk1" style="width:200px;"
  195. placeholder="整数" clearable @keyup.native="addForm.baseRisk1=addForm.baseRisk1.replace(/[^\d]/g,'');"></el-input><span style="margin-left:10px;">元</span>
  196. </div>
  197. <div class="rg_span">
  198. <span style="width:120px;display: inline-block;text-align: right;" v-if="user.company.packageProject==1">预留风险金额2</span>
  199. <el-input @input="addUpfun(addForm.baseRisk2)" v-model="addForm.baseRisk2" style="width:200px;"
  200. placeholder="整数" clearable @keyup.native="addForm.baseRisk2=addForm.baseRisk2.replace(/[^\d]/g,'');"></el-input><span style="margin-left:10px;">元</span>
  201. </div> -->
  202. <!-- 合计 -->
  203. <div style="margin-top: 10px;float:right;">
  204. <span style="margin-right:50px;margin-right:10px;" v-if="user.company.packageProject==1">合计</span>
  205. <span v-if="addForm.budget <= 0 || addForm.budget == undefined">0</span>
  206. <span v-else>{{addForm.budget | numberToCurrency}}</span>
  207. <span style="margin-right:50px;margin-left:10px;">元</span>
  208. </div>
  209. </el-form>
  210. <div slot="footer" class="dialog-footer;">
  211. <el-button @click.native="addFormVisible = false">取消</el-button>
  212. <el-button type="primary" @click="submitInsert" :loading="addLoading">提交</el-button>
  213. </div>
  214. </el-dialog>
  215. <!--用户详细信息弹出框-->
  216. <el-dialog title="查看详情" v-if="userDetailVisible" :visible.sync="userDetailVisible" :close-on-click-modal="false" customClass="customWidth" width="400px">
  217. <div class="line"><span>姓名</span><span>{{userDetail.name}}</span></div>
  218. <div class="line"><span>手机号码</span><span>{{userDetail.phone}}</span></div>
  219. <div class="line"><span>角色</span><span>{{roleArray[userDetail.role]}}</span></div>
  220. <div class="line"><span>部门</span><span>{{userDetail.departmentName}}</span></div>
  221. <div class="line" v-if="user.role>0&&user.role<=3"><span>成本</span><span>{{userDetail.cost}}元/小时</span></div>
  222. <div slot="footer" class="dialog-footer">
  223. <el-button type="primary" @click="userDetailVisible = false" >确定</el-button>
  224. </div>
  225. </el-dialog>
  226. <!-- 子项目列表 -->
  227. <el-dialog title="子项目列表" show-header="false" v-if="subProjectVisible" :visible.sync="subProjectVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  228. <el-table :data="subProjectList" highlight-current-row height="400" style="width: 100%;">
  229. <el-table-column type="index" width="60" label="序号">
  230. <template slot-scope="scope" >
  231. {{scope.$index+1+(page-1)*size}}
  232. </template>
  233. </el-table-column>
  234. <el-table-column prop="name" label="名称" ></el-table-column>
  235. <el-table-column label="操作" width="150">
  236. <template slot-scope="scope" >
  237. <el-button size="small" type="primary" @click="addNewSubProject(scope.row)">编辑</el-button>
  238. <el-button size="small" type="danger" @click="deleteSubPro(scope.row)">删除</el-button>
  239. </template>
  240. </el-table-column>
  241. </el-table>
  242. <div slot="footer" class="dialog-footer">
  243. <el-button type="primary" @click="subProjectVisible = false" >关闭</el-button>
  244. <el-button type="primary" @click="addNewSubProject()" >新增子项目</el-button>
  245. </div>
  246. </el-dialog>
  247. <!-- 新增子项目弹出框 -->
  248. <el-dialog title="新增/修改子项目" v-if="addSubProject" :visible.sync="addSubProject" :close-on-click-modal="false" customClass="customWidth" width="500px">
  249. <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
  250. <el-form-item label="项目名称" prop="name">
  251. <el-input v-model="addForm.name" placeholder="请输入项目名称" clearable></el-input>
  252. </el-form-item>
  253. </el-form>
  254. <div slot="footer" class="dialog-footer">
  255. <el-button @click.native="addSubProject = false">取消</el-button>
  256. <el-button type="primary" @click="submitInsertSubProject" :loading="addLoading">提交</el-button>
  257. </div>
  258. </el-dialog>
  259. <!-- 项目基线成本项配置弹出框 -->
  260. <el-dialog title="项目基线成本项管理" show-header="false" v-if="showBaseConfig" :visible.sync="showBaseConfig" :close-on-click-modal="false" customClass="customWidth" width="500px">
  261. <el-table :data="baseCostItemList" highlight-current-row height="400" style="width: 100%;">
  262. <el-table-column type="index" width="60" label="序号">
  263. <template slot-scope="scope" >
  264. {{scope.$index+1+(page-1)*size}}
  265. </template>
  266. </el-table-column>
  267. <el-table-column prop="name" label="名称" ></el-table-column>
  268. <el-table-column label="操作" width="150">
  269. <template slot-scope="scope" >
  270. <el-button size="small" type="primary" @click="addNewBaseItem(scope.row)">编辑</el-button>
  271. <el-button size="small" type="danger" @click="deleteBaseItem(scope.row)">删除</el-button>
  272. </template>
  273. </el-table-column>
  274. </el-table>
  275. <div slot="footer" class="dialog-footer">
  276. <el-button type="primary" @click="showBaseConfig = false" >关闭</el-button>
  277. <el-button type="primary" @click="addNewBaseItem()" >新增成本项</el-button>
  278. </div>
  279. </el-dialog>
  280. <el-dialog title="新增/修改成本项" v-if="addBaseItemDialog" :visible.sync="addBaseItemDialog" :close-on-click-modal="false" customClass="customWidth" width="500px">
  281. <el-form ref="form2" :model="addForm" :rules="rules" label-width="100px">
  282. <el-form-item label="成本项名称" prop="name">
  283. <el-input v-model="addForm.name" placeholder="请输入名称" clearable></el-input>
  284. </el-form-item>
  285. </el-form>
  286. <div slot="footer" class="dialog-footer">
  287. <el-button @click.native="addBaseItemDialog = false">取消</el-button>
  288. <el-button type="primary" @click="submitInsertBaseItem" :loading="addLoading">提交</el-button>
  289. </div>
  290. </el-dialog>
  291. <!-- 按部门选择人员 -->
  292. <el-dialog title="选择参与人员" v-if="chooseParticipVisible" :visible.sync="chooseParticipVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
  293. <!-- <el-input style="width:100%" v-model="filterName" placeholder="请输入姓名搜索" @change="findUserInTree"></el-input> -->
  294. <div class="tree" style="height:400px">
  295. <el-scrollbar style="height:100%">
  296. <el-tree :data="deptMembData" show-checkbox :props="defaultProps" node-key="id"
  297. ref="chooseMembTree" @check-change="onTreeItemChange" :default-checked-keys="addForm.userId"
  298. highlight-current ></el-tree>
  299. </el-scrollbar>
  300. </div>
  301. <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>
  302. <div slot="footer" class="dialog-footer">
  303. <el-button @click="chooseParticipVisible = false" >取消</el-button>
  304. <el-button type="primary" @click="chooseParticip()" >确定</el-button>
  305. </div>
  306. </el-dialog>
  307. </section>
  308. </template>
  309. <style scoped>
  310. .input-with-select .el-input-group__prepend {
  311. background-color: #fff;
  312. }
  313. .line {
  314. padding:10px;
  315. }
  316. .line span{
  317. font-size:15px;
  318. }
  319. .line span:nth-child(even){
  320. float:right;
  321. }
  322. </style>
  323. <script>
  324. import util from "../../common/js/util";
  325. export default {
  326. data() {
  327. return {
  328. chosenMembCount:0,
  329. chosenMembList:[],//选中的人员
  330. allMembData:[],
  331. deptMembData: [
  332. {
  333. id: 0,
  334. label: '未分配',
  335. }
  336. ],
  337. option: [],
  338. depData: {
  339. id: -1,
  340. label: '全部人员',
  341. },
  342. defaultProps: {
  343. children: 'children',
  344. label: 'label'
  345. },
  346. filterName:null,
  347. chooseParticipVisible: false,
  348. projectBaseCostData:[],
  349. addBaseItemDialog:false,
  350. showBaseConfig:false,
  351. customerList:[],
  352. roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","人事管理员", "项目管理员"],
  353. status:null,
  354. statusTxt:["-","进行中","已完成","已撤销"],
  355. importanceList:[{id:1,label:'正常'},{id:2,label:'紧急'},{id:3,label:'重要'},{id:4,label:'重要且紧急'}],
  356. searchField:null,
  357. keyword:null,
  358. user: JSON.parse(sessionStorage.getItem("user")),
  359. userDetailVisible: false,
  360. userDetail:{},
  361. date: new Date(),
  362. users: [],
  363. participator:[],
  364. tableHeight: 0,
  365. listLoading: false,
  366. total: 0,
  367. page: 1,
  368. size: 20,
  369. list: [],
  370. subProjectVisible: false,
  371. subProjectList: [],//子项目列表
  372. currentProject:{},
  373. addSubProject: false,
  374. addFormVisible: false,
  375. addLoading: false,
  376. addUp: 0, // 合计
  377. title: "",
  378. addForm: {
  379. name: '',
  380. userId: [],
  381. level:1,
  382. },
  383. rules: {
  384. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  385. }
  386. };
  387. },
  388. // 过滤器
  389. filters: {
  390. numberToCurrency(value) {
  391. if (!value) return '0.00'
  392. // 将数值截取,保留两位小数
  393. value = value.toFixed(2)
  394. // 获取整数部分
  395. const intPart = Math.trunc(value)
  396. // 整数部分处理,增加,
  397. const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  398. // 预定义小数部分
  399. let floatPart = '.00'
  400. // 将数值截取为小数部分和整数部分
  401. const valueArray = value.toString().split('.')
  402. if (valueArray.length === 2) { // 有小数部分
  403. floatPart = valueArray[1].toString() // 取得小数部分
  404. return intPartFormat + '.' + floatPart
  405. }
  406. return intPartFormat + floatPart
  407. }
  408. },
  409. methods: {
  410. restrictNumber(targetId) {
  411. let inpu = document.getElementById(targetId);
  412. inpu.value = inpu.value.replace(/[^\d.]/g, ""); //仅保留数字和"."
  413. inpu.value = inpu.value.replace(/\.{2,}/g, "."); //两个连续的"."仅保留第一个"."
  414. inpu.value = inpu.value.replace(".", "$#*").replace(/\./g,'').replace('$#*','.');//去除其他"."
  415. inpu.value = inpu.value.replace(/^(\d+)\.(\d\d).*$/, '$1.$2');;//限制只能输入两个小数
  416. if (inpu.value.indexOf(".") < 0 && inpu.value != "") { //首位是0的话去掉
  417. inpu.value = parseFloat(inpu.value);
  418. }
  419. },
  420. showChooseMembTree() {
  421. this.chosenMembCount = this.participator.length;
  422. this.chooseParticipVisible = true;
  423. },
  424. onTreeItemChange() {
  425. var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
  426. var list = chosenList.filter(item=>item.isUser == 1);
  427. this.chosenMembCount = list.length;
  428. },
  429. findUserInTree() {
  430. if (this.filterName == '') {
  431. this.deptMembData = this.allMembData;
  432. } else {
  433. var list = this.findRecursively(this.filterName, this.allMembData);
  434. this.deptMembData = list;
  435. }
  436. },
  437. findRecursively(username, list) {
  438. var filterList = [];
  439. for (var i=0;i<list.length; i++) {
  440. if (list[i].isUser == 1) {
  441. if (list[i].label.indexOf(username) >= 0) {
  442. //匹配上了
  443. filterList.push(list[i]);
  444. }
  445. } else if (list[i].children != null && list[i].children.length > 0) {
  446. var subList = this.findRecursively(username, list[i].children);
  447. if (subList.length > 0) {
  448. subList.forEach(s=>filterList.push(s));
  449. }
  450. }
  451. }
  452. return filterList;
  453. },
  454. //确定选择参与人
  455. chooseParticip() {
  456. this.chooseParticipVisible = false;
  457. var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
  458. this.chosenMembList = chosenList.filter(item=>item.isUser == 1);
  459. this.addForm.userNames = '';
  460. this.addForm.userId = [];
  461. this.participator = [];
  462. for (var i=0;i<this.chosenMembList.length; i++) {
  463. this.addForm.userId.push(this.chosenMembList[i].id);
  464. this.addForm.userNames += this.chosenMembList[i].label+',';
  465. var item = {id:this.chosenMembList[i].id, name:this.chosenMembList[i].label};
  466. this.participator.push(item);
  467. }
  468. if (this.addForm.userNames.length > 0) {
  469. this.addForm.userNames = this.addForm.userNames.substring(0, this.addForm.userNames.length-1);
  470. }
  471. },
  472. // 获取部门列表
  473. getDepartment() {
  474. this.http.post("/department/listAllMemb", {},
  475. res => {
  476. if (res.code == "ok") {
  477. var list = res.data;
  478. //设置员工到部门下面
  479. this.setUserToDept(list);
  480. this.deptMembData = list;
  481. //用于筛选过滤
  482. this.allMembData = JSON.parse(JSON.stringify(this.deptMembData));
  483. } else {
  484. this.$message({
  485. message: res.msg,
  486. type: "error"
  487. });
  488. }
  489. },
  490. error => {
  491. this.$message({
  492. message: error,
  493. type: "error"
  494. });
  495. });
  496. },
  497. setUserToDept(list) {
  498. for (var i in list) {
  499. if (list[i].children != null) {
  500. this.setUserToDept(list[i].children);
  501. }
  502. if (list[i].userList != null) {
  503. if (list[i].children == null) {
  504. list[i].children = [];
  505. }
  506. list[i].userList.forEach(element => {
  507. var obj = {id: element.id, label:element.name, parentId:element.departmentId, isUser:1};
  508. list[i].children.push(obj);
  509. });
  510. }
  511. }
  512. },
  513. getProjectBaseConfigList() {
  514. this.http.post('/project-basecost-setting/list',{},
  515. res => {
  516. if (res.code == "ok") {
  517. this.baseCostItemList = res.data;
  518. this.$forceUpdate();
  519. } else {
  520. this.$message({
  521. message: res.msg,
  522. type: "error"
  523. });
  524. }
  525. },
  526. error => {
  527. this.$message({
  528. message: error,
  529. type: "error"
  530. });
  531. }
  532. );
  533. },
  534. deleteBaseItem(row) {
  535. this.$confirm("该操作可能造成已有数据丢失,确定要删除吗?","删除成本基线项", {
  536. confirmButtonText: "确定",
  537. cancelButtonText: "取消",
  538. type: "warning"
  539. })
  540. .then(() => {
  541. this.listLoading = true;
  542. this.http.post('/project-basecost-setting/delete',{
  543. id: row.id
  544. },
  545. res => {
  546. this.listLoading = false;
  547. if (res.code == "ok") {
  548. this.$message({
  549. message: "删除成功",
  550. type: "success"
  551. });
  552. this.getProjectBaseConfigList();
  553. } else {
  554. this.$message({
  555. message: res.msg,
  556. type: "error"
  557. });
  558. }
  559. },
  560. error => {
  561. this.listLoading = false;
  562. this.$message({
  563. message: error,
  564. type: "error"
  565. });
  566. }
  567. );
  568. })
  569. .catch(() => {});
  570. },
  571. submitInsertBaseItem() {
  572. this.http.post('/project-basecost-setting/addOrMod',this.addForm,
  573. res => {
  574. if (res.code == "ok") {
  575. this.addBaseItemDialog = false;
  576. this.baseCostItemList = res.data;
  577. this.$forceUpdate();
  578. } else {
  579. this.$message({
  580. message: res.msg,
  581. type: "error"
  582. });
  583. }
  584. },
  585. error => {
  586. this.$message({
  587. message: error,
  588. type: "error"
  589. });
  590. }
  591. );
  592. },
  593. showBaseCostItemDialog() {
  594. this.showBaseConfig = true;
  595. },
  596. addNewBaseItem(row) {
  597. this.addBaseItemDialog = true;
  598. if (row == null) {
  599. this.addForm = {}
  600. } else {
  601. this.addForm = row;
  602. }
  603. },
  604. //获取客户列表
  605. getCustomerList() {
  606. this.http.post('/customer-info/getAll', {
  607. },
  608. res => {
  609. if (res.code == "ok") {
  610. this.customerList = res.data;
  611. } else {
  612. this.$message({
  613. message: res.msg,
  614. type: "error"
  615. });
  616. }
  617. },
  618. error => {
  619. this.$message({
  620. message: error,
  621. type: "error"
  622. });
  623. });
  624. },
  625. importProject(item) {
  626. //首先判断文件类型
  627. let str = item.file.name.split(".");
  628. let format = str[str.length - 1];
  629. if (format != "xls" && format != "xlsx") {
  630. this.$message({
  631. message: "请选择.xls或.xlsx文件",
  632. type: "error"
  633. });
  634. } else {
  635. this.listLoading = true;
  636. let formData = new FormData();
  637. formData.append("file", item.file);
  638. formData.append("userId", this.user.id);
  639. this.http.uploadFile('/project/importData', formData,
  640. res => {
  641. this.$refs.upload.clearFiles();
  642. this.listLoading = false;
  643. if (res.code == "ok") {
  644. this.$message({
  645. message: "导入成功",
  646. type: "success"
  647. });
  648. this.getList();
  649. } else {
  650. this.$message({
  651. message: res.msg,
  652. type: "error"
  653. });
  654. }
  655. },
  656. error => {
  657. this.$refs.upload.clearFiles();
  658. this.listLoading = false;
  659. this.$message({
  660. message: error,
  661. type: "error"
  662. });
  663. });
  664. }
  665. },
  666. number(){  
  667. //     this.addForm.budget = this.addForm.budget.replace(/[^\.\d]/g,'');
  668. // this.addForm.budget = this.addForm.budget.replace('.','');
  669.   },
  670. deleteSubPro(subProject) {
  671. this.$confirm("确定要删除子项目" + subProject.name + "吗?","删除子项目", {
  672. confirmButtonText: "确定",
  673. cancelButtonText: "取消",
  674. type: "warning"
  675. })
  676. .then(() => {
  677. this.listLoading = true;
  678. this.http.post('/sub-project/deleteProject',{
  679. id: subProject.id
  680. },
  681. res => {
  682. this.listLoading = false;
  683. if (res.code == "ok") {
  684. this.$message({
  685. message: "删除成功",
  686. type: "success"
  687. });
  688. this.subProject(this.currentProject);
  689. } else {
  690. this.$message({
  691. message: res.msg,
  692. type: "error"
  693. });
  694. }
  695. },
  696. error => {
  697. this.listLoading = false;
  698. this.$message({
  699. message: error,
  700. type: "error"
  701. });
  702. }
  703. );
  704. })
  705. .catch(() => {});
  706. },
  707. searchList() {
  708. this.page = 1;
  709. this.getList();
  710. },
  711. addNewSubProject(subProject) {
  712. console.log(123);
  713. if (subProject == null) {
  714. this.addForm = {projectId: this.currentProject.id, level:1}
  715. } else {
  716. this.addForm = subProject;
  717. }
  718. this.addSubProject = true;
  719. },
  720. //显示子项目
  721. subProject(item) {
  722. this.subProjectVisible = true;
  723. this.currentProject = item;
  724. this.http.post('/sub-project/list', {
  725. projectId: item.id
  726. },
  727. res => {
  728. if (res.code == "ok") {
  729. this.subProjectList = res.data;
  730. } else {
  731. this.$message({
  732. message: res.msg,
  733. type: "error"
  734. });
  735. }
  736. },
  737. error => {
  738. this.$message({
  739. message: error,
  740. type: "error"
  741. });
  742. });
  743. },
  744. //显示用户详情
  745. showUser(userId) {
  746. this.userDetailVisible = true;
  747. this.http.post(this.port.manage.userDetail, {
  748. userId: userId
  749. },
  750. res => {
  751. if (res.code == "ok") {
  752. this.userDetail = res.data;
  753. } else {
  754. this.$message({
  755. message: res.msg,
  756. type: "error"
  757. });
  758. }
  759. },
  760. error => {
  761. this.$message({
  762. message: error,
  763. type: "error"
  764. });
  765. });
  766. },
  767. //选择参与人
  768. changeParticipator() {
  769. //检查是否在参与人中,如果没有需要加入到参与人中
  770. this.participator = [];
  771. this.addForm.userId.forEach(u=>{
  772. var list = this.users.filter(au=>au.id == u);
  773. if (list.length > 0) {
  774. var findUser = list[0];
  775. this.participator.push(findUser);
  776. } else {
  777. console.log('未找到用户: '+u);
  778. }
  779. })
  780. },
  781. getUsers() {
  782. this.http.post(this.port.manage.list, {
  783. departmentId: -1,
  784. pageIndex: 1,
  785. pageSize: 99999
  786. },
  787. res => {
  788. if (res.code == "ok") {
  789. this.users = res.data.records;
  790. } else {
  791. this.$message({
  792. message: res.msg,
  793. type: "error"
  794. });
  795. }
  796. },
  797. error => {
  798. this.$message({
  799. message: error,
  800. type: "error"
  801. });
  802. });
  803. },
  804. //分页
  805. handleCurrentChange(val) {
  806. this.page = val;
  807. this.getList();
  808. },
  809. handleSizeChange(val) {
  810. this.size = val;
  811. this.getList();
  812. },
  813. //获取项目列表
  814. getList() {
  815. this.listLoading = true;
  816. this.http.post(this.port.project.listPage, {
  817. pageIndex: this.page,
  818. pageSize: this.size,
  819. keyword:this.keyword,
  820. searchField: this.searchField,
  821. status: this.status
  822. },
  823. res => {
  824. this.listLoading = false;
  825. if (res.code == "ok") {
  826. var list = res.data.records;
  827. for(var i in list) {
  828. var participator = list[i].participator , str = "";
  829. for(var j in participator) {
  830. if(j == participator.length-1) {
  831. str += participator[j].name
  832. } else {
  833. str += participator[j].name + ','
  834. }
  835. }
  836. list[i].userNames = str;
  837. }
  838. this.list = list;
  839. this.total = res.data.total;
  840. } else {
  841. this.$message({
  842. message: res.msg,
  843. type: "error"
  844. });
  845. }
  846. },
  847. error => {
  848. this.listLoading = false;
  849. this.$message({
  850. message: error,
  851. type: "error"
  852. });
  853. });
  854. },
  855. //显示新增界面
  856. handleAdd(i, item) {
  857. if(i == -1) {
  858. this.title = "新增项目";
  859. this.addForm = {
  860. name: '',
  861. userId: [],
  862. userNames:'',
  863. code:'',
  864. inchargerId:null,
  865. level:1,
  866. customerId:null,
  867. }
  868. this.projectBaseCostData = [];
  869. for (var m=0;m<this.baseCostItemList.length; m++) {
  870. this.projectBaseCostData.push({baseId: this.baseCostItemList[m].id, baseName:this.baseCostItemList[m].name, baseAmount:0});
  871. }
  872. } else {
  873. this.title = "修改项目";
  874. var list = item.participator , arr = [];
  875. var names = '';
  876. for(var j in list) {
  877. arr.push(list[j].id)
  878. names += list[j].name+',';
  879. }
  880. if (names.length > 0) {
  881. names = names.substring(0, names.length -1);
  882. }
  883. this.addForm = {
  884. id: item.id,
  885. name: item.projectName,
  886. userId: arr,
  887. userNames:names,
  888. code:item.projectCode,
  889. inchargerId: item.inchargerId,
  890. level: item.level,
  891. planStartDate: item.planStartDate,
  892. planEndDate: item.planEndDate,
  893. budget: item.budget,
  894. baseMan: item.baseMan,
  895. contractAmount: item.contractAmount,
  896. baseFee: item.baseFee,
  897. baseRisk1: item.baseRisk1,
  898. baseRisk2: item.baseRisk2,
  899. baseOutsourcing: item.baseOutsourcing,
  900. customerId:item.customerId==0?null:item.customerId,
  901. }
  902. this.changeParticipator();
  903. this.getProjectBaseData(item.id);
  904. }
  905. this.addFormVisible = true;
  906. },
  907. getProjectBaseData(projectId) {
  908. this.http.post('/project-basecost/get',{projectId: projectId},
  909. res => {
  910. if (res.code == "ok") {
  911. this.projectBaseCostData = res.data;
  912. } else {
  913. this.$message({
  914. message: res.msg,
  915. type: "error"
  916. });
  917. }
  918. },
  919. error => {
  920. this.listLoading = false;
  921. this.$message({
  922. message: error,
  923. type: "error"
  924. });
  925. }
  926. );
  927. },
  928. //提交子项目创建修改请求
  929. submitInsertSubProject () {
  930. this.$refs.form2.validate(valid => {
  931. if (valid) {
  932. this.http.post('/sub-project/saveOrUpdate',this.addForm,
  933. res => {
  934. if (res.code == "ok") {
  935. this.$message({
  936. message: "操作成功",
  937. type: "success"
  938. });
  939. this.subProject(this.currentProject);
  940. this.addSubProject = false;
  941. } else {
  942. this.$message({
  943. message: res.msg,
  944. type: "error"
  945. });
  946. }
  947. },
  948. error => {
  949. this.listLoading = false;
  950. this.$message({
  951. message: error,
  952. type: "error"
  953. });
  954. }
  955. );
  956. }
  957. });
  958. },
  959. // 项目基线合计
  960. addUpfun() {
  961. var total = 0;
  962. for (var i=0;i<this.projectBaseCostData.length; i++) {
  963. total += parseFloat(this.projectBaseCostData[i].baseAmount);
  964. }
  965. this.addForm.budget = total;
  966. // var a = '0'
  967. // var q = '0'
  968. // var w = '0'
  969. // var e = '0'
  970. // var r = '0'
  971. // // this.addForm.baseMan === undefined || this.addForm.baseMan === NaN ? this.addForm.baseMa = '0' : this.addForm.baseMan
  972. // if (this.addForm.baseMan == undefined || this.addForm.baseMan == NaN) {
  973. // a = 0
  974. // } else {
  975. // a = this.addForm.baseMan
  976. // }
  977. // if (this.addForm.baseFee !== undefined) q = this.addForm.baseFee
  978. // if (this.addForm.baseOutsourcing !== undefined) w = this.addForm.baseOutsourcing
  979. // if (this.addForm.baseRisk1 !== undefined) e = this.addForm.baseRisk1
  980. // if (this.addForm.baseRisk2 !== undefined) r = this.addForm.baseRisk2
  981. // this.addForm.budget = +a + +q + +w + +e + +r
  982. },
  983. submitInsert() {
  984. this.$refs.form1.validate(valid => {
  985. if (valid) {
  986. this.addLoading = true;
  987. let formData = new FormData();
  988. formData.append("name", this.addForm.name);
  989. if(this.addForm.id != null) {
  990. formData.append("id", this.addForm.id);
  991. }
  992. if(this.addForm.userId.length != 0) {
  993. for(var j in this.addForm.userId) {
  994. formData.append("userId", this.addForm.userId[j]);
  995. }
  996. }
  997. if(this.addForm.inchargerId != null) {
  998. formData.append("inchargerId", this.addForm.inchargerId);
  999. }
  1000. if(this.addForm.code != null) {
  1001. formData.append("code", this.addForm.code);
  1002. }
  1003. if(this.addForm.planStartDate != null) {
  1004. formData.append("planStartDate", this.addForm.planStartDate);
  1005. }
  1006. if(this.addForm.planEndDate != null) {
  1007. formData.append("planEndDate", this.addForm.planEndDate);
  1008. }
  1009. if(this.addForm.level != null) {
  1010. formData.append("level", this.addForm.level);
  1011. }
  1012. if(this.addForm.contractAmount != null) {
  1013. formData.append("contractAmount", this.addForm.contractAmount);
  1014. }
  1015. if (this.projectBaseCostData != null) {
  1016. formData.append("projectBaseCostData", JSON.stringify(this.projectBaseCostData));
  1017. //计算总预算成本
  1018. if (this.addForm.budget == null) {
  1019. this.addForm.budget = 0;
  1020. }
  1021. formData.append("budget", this.addForm.budget);
  1022. }
  1023. if (this.addForm.customerId == null) {
  1024. formData.append("customerId", 0);
  1025. } else {
  1026. formData.append("customerId", this.addForm.customerId);
  1027. }
  1028. this.http.uploadFile(this.port.project.add,formData,
  1029. res => {
  1030. this.addLoading = false;
  1031. if (res.code == "ok") {
  1032. this.$message({
  1033. message: (this.addForm.id!=null?'修改':'创建')+"成功",
  1034. type: "success"
  1035. });
  1036. this.addFormVisible = false;
  1037. this.getList();
  1038. } else {
  1039. this.$message({
  1040. message: res.msg,
  1041. type: "error"
  1042. });
  1043. }
  1044. },
  1045. error => {
  1046. this.addLoading = false;
  1047. this.$message({
  1048. message: error,
  1049. type: "error"
  1050. });
  1051. });
  1052. }
  1053. });
  1054. },
  1055. // 删除
  1056. deletePro(i, item) {
  1057. this.$confirm("确定要项目" + item.projectName + "吗?","删除项目", {
  1058. confirmButtonText: "确定",
  1059. cancelButtonText: "取消",
  1060. type: "warning"
  1061. })
  1062. .then(() => {
  1063. this.listLoading = true;
  1064. this.http.post(this.port.project.delete,{
  1065. id: item.id
  1066. },
  1067. res => {
  1068. this.listLoading = false;
  1069. if (res.code == "ok") {
  1070. this.$message({
  1071. message: "删除成功",
  1072. type: "success"
  1073. });
  1074. this.getList();
  1075. } else {
  1076. this.$message({
  1077. message: res.msg,
  1078. type: "error"
  1079. });
  1080. }
  1081. },
  1082. error => {
  1083. this.listLoading = false;
  1084. this.$message({
  1085. message: error,
  1086. type: "error"
  1087. });
  1088. }
  1089. );
  1090. })
  1091. .catch(() => {});
  1092. },
  1093. detail(i) {
  1094. this.$router.push("/list/" + this.list[i].id + "/" + this.list[i].projectName);
  1095. }
  1096. },
  1097. created() {
  1098. let height = window.innerHeight;
  1099. this.tableHeight = height - 195;
  1100. const that = this;
  1101. window.onresize = function temp() {
  1102. that.tableHeight = window.innerHeight - 195;
  1103. };
  1104. },
  1105. mounted() {
  1106. this.getDepartment();
  1107. this.getList();
  1108. this.getUsers();
  1109. this.getCustomerList();
  1110. this.getProjectBaseConfigList();
  1111. }
  1112. };
  1113. </script>
  1114. <style lang="scss" scoped>
  1115. .rg_span{
  1116. display: inline-block;
  1117. }
  1118. .rg_span span {
  1119. text-align: right;
  1120. box-sizing: border-box;
  1121. padding-right: 10px;
  1122. }
  1123. .el-dialog__title {
  1124. display: inline-table;
  1125. margin-top: 20px;
  1126. }
  1127. </style>