list.vue 46 KB

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