projectDetail.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  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>
  7. <el-button type="text" @click="backToList" icon="el-icon-back" class="back">返回</el-button>
  8. </el-form-item>
  9. <el-form-item class="divLine">
  10. </el-form-item>
  11. <el-form-item>
  12. <span class="projectTitle">{{proDetail.projectName}}</span>
  13. </el-form-item>
  14. </el-form>
  15. </el-col>
  16. <el-col :span="24" :style="allDetail">
  17. <el-col :span="24" class="title">项目基本信息
  18. <i class="el-icon-edit editDetail" v-if="user.id == proDetail.managerId || user.id == proDetail.creatorId" @click="edit"></i>
  19. </el-col>
  20. <el-col :span="24" class="main">
  21. <el-col :span="6" class="detail">
  22. 项目编号:
  23. <span class="info">{{proDetail.projectNo}}</span>
  24. </el-col>
  25. <el-col :span="6" class="detail">
  26. 项目经理:
  27. <span class="info">{{proDetail.manager}}</span>
  28. </el-col>
  29. <el-col :span="6" class="detail">
  30. 资产方审批人:
  31. <span class="info">{{proDetail.ownerApprover}}</span>
  32. </el-col>
  33. <el-col :span="6" class="detail">
  34. 生产方审批人:
  35. <span class="info">{{proDetail.customerApprover}}</span>
  36. </el-col>
  37. <el-col :span="24" class="detail">
  38. 生产方公司:
  39. <span class="info" v-for="(item, index) in proDetail.customCompanies">
  40. {{item.companyName}}
  41. <span v-if="index != proDetail.customCompanies.length-1">、</span>
  42. </span>
  43. </el-col>
  44. <!-- <el-col :span="24" class="detail">
  45. 项目模具:
  46. <span class="info model" v-for="(item, index) in proDetail.models">
  47. <span @click="toMold(item.id)">{{item.modelName}}({{item.modelNo}})</span>
  48. <span v-if="index != proDetail.models.length-1">、</span>
  49. </span>
  50. </el-col> -->
  51. <el-col :span="24" class="detail">
  52. 普通成员:
  53. <span class="info" v-for="(item, index) in proDetail.participateUsers">
  54. {{item.username}}
  55. <span v-if="index != proDetail.participateUsers.length-1">、</span>
  56. </span>
  57. </el-col>
  58. <!-- <el-col :span="24" class="detail">
  59. 生产方人员:
  60. <span class="info" v-for="(item, index) in proDetail.customUsers">
  61. {{item.username}}
  62. <span v-if="index != proDetail.customUsers.length-1">、</span>
  63. </span>
  64. </el-col> -->
  65. </el-col>
  66. <el-col :span="24">
  67. <el-collapse class="activeNames" v-model="activeNames">
  68. <el-collapse-item name="1">
  69. <template slot="title">
  70. <el-col :span="24" class="title">项目模具</el-col>
  71. </template>
  72. <el-col :span="24" class="detail">
  73. <el-table :data="proDetail.models" highlight-current-row v-loading="modelsLoading" style="width: 100%;">
  74. <el-table-column type="index" width="40"></el-table-column>
  75. <el-table-column prop="modelNo" label="模具编号" width="200" sortable>
  76. <template slot-scope="scope">
  77. <span class="model" @click="toMold(scope.row.id)">{{scope.row.modelNo}}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="modelName" label="模具名称" width="500" sortable></el-table-column>
  81. <el-table-column prop="produceCompanyName" label="所属生产商" sortable></el-table-column>
  82. </el-table>
  83. </el-col>
  84. </el-collapse-item>
  85. <el-collapse-item name="2">
  86. <template slot="title">
  87. <el-col :span="24" class="title">项目文档
  88. <!-- update == 1 -->
  89. <el-upload v-if="user.id == proDetail.managerId" ref="upload" action="customize" :http-request="uploadFile" :show-file-list="false" :limit="1" style="float:right;margin-right:20px;">
  90. <el-button size="mini" type="primary" :loading="upLoading">点击上传</el-button>
  91. </el-upload>
  92. </el-col>
  93. </template>
  94. <el-col :span="24" class="detail">
  95. <el-table :data="files" highlight-current-row v-loading="listLoading" style="width: 100%;">
  96. <el-table-column type="index" width="40"></el-table-column>
  97. <el-table-column prop="fileName" label="名称" sortable></el-table-column>
  98. <el-table-column prop="fileSize" label="大小" width="150" align="center" sortable></el-table-column>
  99. <el-table-column prop="uploader" label="上传者" width="120" align="center" sortable></el-table-column>
  100. <el-table-column prop="indate" label="上传时间" width="200" align="center" sortable></el-table-column>
  101. <el-table-column label="操作" width="220" align="center" sortable>
  102. <template slot-scope="scope" v-if="download == 1">
  103. <el-button size="small" @click="dowloadFile(scope.row.id)">
  104. <a :href="scope.row.url" :download="scope.row.fileName">下载</a>
  105. </el-button>
  106. <el-button size="small" type="danger" @click="fileDel(scope.row.id)" v-if="scope.row.uploaderId == user.id">删除</el-button>
  107. </template>
  108. <template slot-scope="scope" v-else>
  109. -
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. </el-col>
  114. </el-collapse-item>
  115. <el-collapse-item name="3">
  116. <template slot="title">
  117. <el-col :span="24" class="title">操作记录</el-col>
  118. </template>
  119. <el-col :span="24" class="detail">
  120. <el-table :data="opers" highlight-current-row v-loading="oplistLoading" style="width: 100%;">
  121. <el-table-column type="index" width="40"></el-table-column>
  122. <el-table-column prop="content" label="操作" width="120" sortable></el-table-column>
  123. <el-table-column prop="fileName" label="操作文档名称" sortable></el-table-column>
  124. <el-table-column prop="operator" label="操作人" width="120" align="center" sortable></el-table-column>
  125. <el-table-column prop="indate" label="操作时间" width="200" align="center" sortable></el-table-column>
  126. </el-table>
  127. </el-col>
  128. </el-collapse-item>
  129. </el-collapse>
  130. </el-col>
  131. </el-col>
  132. <!--编辑界面-->
  133. <el-dialog title="编辑项目" v-if="editFormVisible" :visible.sync="editFormVisible" :close-on-click-modal="false" customClass='customWidth'>
  134. <el-form :model="editForm" label-width="120px" :rules="formRules" ref="editForm">
  135. <el-col :span="24">
  136. <el-form-item label="项目名称" prop="projectName">
  137. <el-input v-model="editForm.projectName" autocomplete="off" placeholder="请输入项目名称" style="width:510px"></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="24">
  141. <el-form-item label="项目模具" prop="modelIds">
  142. <el-select v-model="editForm.modelIds" @change="companyChange" clearable filterable multiple placeholder="请选择项目模具" value-key='id' style="width:510px">
  143. <el-option v-for="item in molds" :key="item.id" :label="item.modelName" :value="item">
  144. <span style="float: left">{{ item.modelName }}</span>
  145. <span style="float: right; color: #8492a6; font-size: 6px;margin-right:17px;">{{ item.produceCompany }}</span>
  146. </el-option>
  147. </el-select>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="24">
  151. <el-form-item label="项目经理" prop="managerId">
  152. <el-select v-model="editForm.managerId" @change="changeStaff(0)" clearable filterable placeholder="请选择项目经理" value-key='id' style="width:510px">
  153. <el-option v-for="item in charger" :key="item.id" :label="item.username" :value="item">
  154. </el-option>
  155. </el-select>
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="12">
  159. <el-form-item label="资产方审批人" prop="ownerApproverId">
  160. <el-select v-model="editForm.ownerApproverId" @change="changeStaff(0)" clearable filterable placeholder="请选择资产方审批人" value-key='id' style="width:190px">
  161. <el-option v-for="item in assets" :key="item.id" :label="item.username" :value="item.id">
  162. </el-option>
  163. </el-select>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="12">
  167. <el-form-item label="生产方审批人" prop="customerApproverId">
  168. <el-select v-model="editForm.customerApproverId" @change="changeStaff(0)" clearable filterable placeholder="请选择生产方审批人" value-key='id' style="width:190px">
  169. <el-option v-for="item in produce" :key="item.id" :label="item.username" :value="item.id">
  170. </el-option>
  171. </el-select>
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="24">
  175. <el-form-item label="项目普通用户">
  176. <el-select v-model="editForm.users" @change="changeStaff(1)" clearable filterable multiple placeholder="请选择项目普通用户" style="width:510px">
  177. <el-option v-for="item in general" :key="item.id" :label="item.username" :value="item.id">
  178. </el-option>
  179. </el-select>
  180. </el-form-item>
  181. </el-col>
  182. <!-- <el-col :span="24">
  183. <el-form-item label="资产方参与人">
  184. <el-select v-model="editForm.assets" clearable filterable multiple placeholder="请选择资产方参与人" style="width:510px">
  185. <el-option v-for="item in assets" :key="item.id" :label="item.username" :value="item.id">
  186. </el-option>
  187. </el-select>
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="24">
  191. <el-form-item label="生产方参与人">
  192. <el-select v-model="editForm.produce" clearable filterable multiple placeholder="请选择生产方参与人" style="width:510px">
  193. <el-option v-for="item in produce" :key="item.id" :label="item.username" :value="item.id">
  194. </el-option>
  195. </el-select>
  196. </el-form-item>
  197. </el-col> -->
  198. </el-form>
  199. <div slot="footer" class="dialog-footer">
  200. <el-button size="small" style="float:left;margin-left:20px;" type="primary" @click.native="addStaff" :loading="editLoading">添加人员</el-button>
  201. <el-button @click.native="editFormVisible = false">取消</el-button>
  202. <el-button type="primary" @click.native="addSubmit" :loading="editLoading">提交</el-button>
  203. </div>
  204. </el-dialog>
  205. <!--新增界面-->
  206. <el-dialog title="新增人员" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass='customWidth'>
  207. <el-form :model="addForm" label-width="100px" :rules="formRules" ref="addForm" :inline="true" class="demo-form-inline">
  208. <el-form-item label="姓名" prop="username">
  209. <el-input v-model="addForm.username" autocomplete="off" placeholder="请输入姓名"></el-input>
  210. </el-form-item>
  211. <el-form-item label="手机号" prop="account">
  212. <el-input v-model="addForm.account" autocomplete="off" placeholder="请输入手机号(登录账号)"></el-input>
  213. </el-form-item>
  214. <el-form-item label="公司" prop="companyId">
  215. <el-select v-model="addForm.companyId" clearable filterable placeholder="请选择所属公司" style="width:202px">
  216. <el-option v-for="item in staffComp" :key="item.id" :label="item.companyName" :value="item.id">
  217. </el-option>
  218. </el-select>
  219. </el-form-item>
  220. <el-form-item label="角色">
  221. <el-input v-model="addForm.roleName" autocomplete="off" placeholder="请输入角色名称"></el-input>
  222. </el-form-item>
  223. </el-form>
  224. <div slot="footer" class="dialog-footer">
  225. <span style="color:#f00;float:left;margin-left:60px;">初始密码:000000</span>
  226. <el-button @click.native="addFormVisible = false">取消</el-button>
  227. <el-button type="primary" @click.native="addPeople(1)" :loading="addLoading">提交并新增</el-button>
  228. <el-button type="primary" @click.native="addPeople(0)" :loading="addLoading">提交</el-button>
  229. </div>
  230. </el-dialog>
  231. </section>
  232. </template>
  233. <script>
  234. import util from "../../common/js/util";
  235. export default {
  236. data() {
  237. var checkPhone = (rule, value, callback) => {
  238. if (!value) {
  239. return callback(new Error('请输入联系方式'));
  240. } else {
  241. const reg = /^1[0-9]\d{9}$/
  242. if (reg.test(value)) {
  243. callback();
  244. } else {
  245. return callback(new Error('请输入正确的联系方式'));
  246. }
  247. }
  248. };
  249. return {
  250. activeNames: ['1','2','3'],
  251. detailId: this.$route.params.id,
  252. user: JSON.parse(sessionStorage.getItem('user')),
  253. //临时数据
  254. proDetail: {},
  255. files: [],
  256. opers: [],
  257. allDetail: {
  258. overflow: 'auto',
  259. padding: '0px 5px',
  260. height: 0
  261. },
  262. listLoading: false,
  263. modelsLoading: false,
  264. upLoading: false,
  265. oplistLoading: false,
  266. activePage: 0,
  267. update: 0,
  268. download: 0,
  269. view: 0,
  270. approve: 0,
  271. company: [],
  272. staffComp: [],
  273. allUser: [],
  274. assets: [],
  275. produce: [],
  276. charger: [],
  277. general: [],
  278. formRules: {
  279. projectName: [
  280. { required: true, message: '请输入项目名称', trigger: 'blur' }
  281. ],
  282. customerCompany: [
  283. { required: true, message: '请选择客户公司', trigger: 'blur' }
  284. ],
  285. modelIds: [
  286. { required: true, message: '请选择项目模具', trigger: ['blur','change'] }
  287. ],
  288. managerId: [
  289. { required: true, message: '请选择项目经理', trigger: ['blur','change'] }
  290. ],
  291. ownerApproverId: [
  292. { required: true, message: '请选择资产方审批人', trigger: ['blur','change'] }
  293. ],
  294. customerApproverId: [
  295. { required: true, message: '请选择生产方审批人', trigger: ['blur','change'] }
  296. ],
  297. // 新建人员
  298. username: [
  299. { required: true, message: '请输入姓名', trigger: 'blur' }
  300. ],
  301. account: [
  302. { required: true, validator: checkPhone, trigger: 'blur'}
  303. ],
  304. teamName: [
  305. { required: true, message: '请选择人员类型', trigger: ["blur",'change'] }
  306. ],
  307. companyId: [
  308. { required: true, message: '请选择所属公司', trigger: ["blur",'change'] }
  309. ],
  310. },
  311. editFormVisible: false,//编辑界面是否显示
  312. editLoading: false,
  313. //编辑界面数据
  314. editForm: {
  315. projectName: '',
  316. customerCompany: [],
  317. managerId: '',
  318. ownerApproverId: '',
  319. customerApproverId: '',
  320. modelIds: [],
  321. users: []
  322. },
  323. //新增界面是否显示
  324. addFormVisible: false,
  325. addLoading: false,
  326. //新增界面数据
  327. addForm: {
  328. username: '',
  329. account: '',
  330. companyId: '',
  331. roleName: '',
  332. flag: 0
  333. },
  334. };
  335. },
  336. methods: {
  337. //返回
  338. backToList() {
  339. this.$router.go(-1);
  340. },
  341. toMold(id) {
  342. this.$router.push('/moldList/' + id);
  343. },
  344. handleClick(tab, event) {
  345. },
  346. //获取详情
  347. getDetail() {
  348. this.modelsLoading = true;
  349. this.http.post(this.port.project.projectDetail, {
  350. id: this.detailId
  351. }, res => {
  352. this.modelsLoading = false;
  353. if (res.code == "ok") {
  354. this.update = res.data.update;
  355. this.download = res.data.download;
  356. this.view = res.data.view;
  357. this.approve = res.data.approve;
  358. var list = res.data.vo;
  359. var approves = res.data.vo.approves;
  360. for(var i in approves){
  361. if(approves[i].subordinateType == 0){
  362. list.ownerApprover = approves[i].approverName;
  363. } else {
  364. list.customerApprover = approves[i].approverName;
  365. }
  366. }
  367. this.proDetail = list;
  368. if(this.user.parentId != 0){
  369. this.getMsg();
  370. this.getStaff();
  371. }
  372. } else {
  373. this.$message({
  374. message: res.msg,
  375. type: 'error'
  376. });
  377. }
  378. }, error => {
  379. this.modelsLoading = false;
  380. this.$message({
  381. message: error,
  382. type: 'error'
  383. });
  384. })
  385. },
  386. getFileList() {
  387. this.listLoading = true;
  388. // 获取文档列表
  389. this.http.post(this.port.project.fileList, {
  390. projectId: this.detailId
  391. }, res => {
  392. this.listLoading = false;
  393. if (res.code == "ok") {
  394. this.files = res.data;
  395. } else {
  396. this.$message({
  397. message: res.msg,
  398. type: 'error'
  399. });
  400. }
  401. }, error => {
  402. this.listLoading = false;
  403. this.$message({
  404. message: error,
  405. type: 'error'
  406. });
  407. })
  408. },
  409. getOperList() {
  410. this.oplistLoading = true;
  411. // 获取文档列表
  412. this.http.post(this.port.project.operList, {
  413. projectId: this.detailId
  414. }, res => {
  415. this.oplistLoading = false;
  416. if (res.code == "ok") {
  417. this.opers = res.data;
  418. } else {
  419. this.$message({
  420. message: res.msg,
  421. type: 'error'
  422. });
  423. }
  424. }, error => {
  425. this.oplistLoading = false;
  426. this.$message({
  427. message: error,
  428. type: 'error'
  429. });
  430. })
  431. },
  432. //获取信息
  433. getMsg() {
  434. // 获取公司
  435. this.http.post(this.port.base.addCompanyListToProject, {
  436. parentId: this.user.parentId,
  437. id: this.user.id
  438. }, res => {
  439. if (res.code == "ok") {
  440. var list = res.data , array = [];
  441. for(var i in list){
  442. if(list[i].id != this.proDetail.ownerCompany){
  443. array.push(list[i])
  444. }
  445. }
  446. this.company = array;
  447. } else {
  448. this.$message({
  449. message: res.msg,
  450. type: 'error'
  451. });
  452. }
  453. }, error => {
  454. this.$message({
  455. message: error,
  456. type: 'error'
  457. });
  458. })
  459. // 获取模具
  460. this.http.post(this.port.mold.modelList, {
  461. parentId: this.user.parentId,
  462. id: this.user.id
  463. }, res => {
  464. if (res.code == "ok") {
  465. this.molds = res.data;
  466. } else {
  467. this.$message({
  468. message: res.msg,
  469. type: 'error'
  470. });
  471. }
  472. }, error => {
  473. this.$message({
  474. message: error,
  475. type: 'error'
  476. });
  477. })
  478. this.http.post(this.port.base.getCompanyByPro, {
  479. projectId: this.detailId
  480. }, res => {
  481. if (res.code == "ok") {
  482. this.staffComp = res.data;
  483. } else {
  484. this.$message({
  485. message: res.msg,
  486. type: 'error'
  487. });
  488. }
  489. }, error => {
  490. this.$message({
  491. message: error,
  492. type: 'error'
  493. });
  494. })
  495. },
  496. // 获取人员
  497. getStaff() {
  498. // 获取人员
  499. var compIds = this.proDetail.ownerCompany;
  500. for(var i in this.proDetail.customCompanies){
  501. compIds += "," + this.proDetail.customCompanies[i].companyId;
  502. }
  503. this.http.post(this.port.project.getUserById, {
  504. companyIds: compIds,
  505. id: this.user.id
  506. } , res => {
  507. if (res.code == "ok") {
  508. var list = res.data , assets = [] , produce = [];
  509. for(var i in list) {
  510. if(list[i].companyId == this.proDetail.ownerCompany){
  511. if(list[i].id != this.user.id){
  512. if(list[i].id != this.proDetail.managerId){
  513. assets.push(list[i])
  514. }
  515. }
  516. } else {
  517. produce.push(list[i])
  518. }
  519. }
  520. this.allUser = res.data;
  521. this.charger = res.data;
  522. this.assets = assets;
  523. this.produce = produce;
  524. this.general = res.data;
  525. this.setMember();
  526. } else {
  527. this.$message({
  528. message: res.msg,
  529. type: 'error'
  530. });
  531. }
  532. }, error => {
  533. this.$message({
  534. message: error,
  535. type: 'error'
  536. });
  537. })
  538. },
  539. //切换人员
  540. changeStaff(i) {
  541. if(i == 0){
  542. var list = this.allUser , array = [];
  543. for(var i in list){
  544. if(list[i].id != this.editForm.customerApproverId && list[i].id != this.editForm.managerId.id && list[i].id != this.editForm.ownerApproverId){
  545. array.push(list[i])
  546. }
  547. }
  548. this.general = array;
  549. } else if(i == 1) {
  550. var list = this.allUser , str = this.editForm.users.toString() , array = [] , assets = [] , produce = [];
  551. for(var i in list) {
  552. if(str.indexOf(list[i].id) == -1) {
  553. array.push(list[i]);
  554. }
  555. }
  556. for(var i in list) {
  557. if(str.indexOf(list[i].id) == -1) {
  558. if(list[i].subordinateType == 0){
  559. assets.push(list[i])
  560. } else {
  561. produce.push(list[i])
  562. }
  563. }
  564. }
  565. this.charger = array;
  566. this.assets = assets;
  567. this.produce = produce;
  568. }
  569. },
  570. //选择公司切换人员
  571. companyChange() {
  572. var param = {} ,
  573. str = this.proDetail.ownerCompany;
  574. for(var i in this.editForm.modelIds){
  575. str += "," + this.editForm.modelIds[i].produceCompanyId;
  576. }
  577. param.companyIds = str;
  578. param.id = this.user.id
  579. this.http.post(this.port.project.getUserById, param , res => {
  580. if (res.code == "ok") {
  581. var list = res.data , assets = [] , produce = [];
  582. for(var i in list) {
  583. if(list[i].companyId == this.proDetail.ownerCompany){
  584. if(list[i].id != this.user.id){
  585. if(list[i].id != this.proDetail.managerId){
  586. assets.push(list[i])
  587. }
  588. }
  589. } else {
  590. produce.push(list[i])
  591. }
  592. }
  593. this.allUser = res.data;
  594. this.charger = res.data;
  595. this.assets = assets;
  596. this.produce = produce;
  597. this.general = res.data;
  598. this.setMember();
  599. } else {
  600. this.$message({
  601. message: res.msg,
  602. type: 'error'
  603. });
  604. }
  605. }, error => {
  606. this.$message({
  607. message: error,
  608. type: 'error'
  609. });
  610. })
  611. },
  612. //打开编辑页面
  613. edit() {
  614. var compArr = [] ,
  615. manager = {} ,
  616. ownerApproverId = '' ,
  617. customerApproverId = '' ,
  618. moldArr = [] ,
  619. assets = [] ,
  620. produce = [] ,
  621. users = [];
  622. for(var i in this.proDetail.customCompanies){
  623. for(var j in this.company){
  624. if(this.company[j].id == this.proDetail.customCompanies[i].companyId){
  625. compArr.push(this.company[j])
  626. }
  627. }
  628. }
  629. for(var i in this.charger){
  630. if(this.charger[i].id == this.proDetail.managerId){
  631. manager = this.charger[i];
  632. }
  633. }
  634. for(var i in this.proDetail.approves) {
  635. if(this.proDetail.approves[i].subordinateType == 0){
  636. ownerApproverId = this.proDetail.approves[i].approverId;
  637. } else {
  638. customerApproverId = this.proDetail.approves[i].approverId;
  639. }
  640. }
  641. for(var i in this.molds){
  642. for(var j in this.proDetail.models){
  643. if(this.molds[i].id == this.proDetail.models[j].id){
  644. moldArr.push(this.proDetail.models[j])
  645. }
  646. }
  647. }
  648. for(var i in this.proDetail.participateUsers){
  649. users.push(this.proDetail.participateUsers[i].id)
  650. }
  651. this.editForm = {
  652. id: this.proDetail.id,
  653. projectName: this.proDetail.projectName,
  654. customerCompany: compArr,
  655. managerId: manager,
  656. ownerApproverId: ownerApproverId,
  657. customerApproverId: customerApproverId,
  658. modelIds: moldArr,
  659. users: users
  660. }
  661. this.setMember();
  662. this.editFormVisible = true;
  663. },
  664. setMember() {
  665. var list = this.allUser , array = [];
  666. for(var i in list){
  667. if(list[i].id != this.editForm.customerApproverId && list[i].id != this.editForm.managerId.id && list[i].id != this.editForm.ownerApproverId){
  668. array.push(list[i])
  669. }
  670. }
  671. this.general = array;
  672. var list = this.allUser , str = this.editForm.users.toString() , newArray = [] , assets = [] , produce = [];
  673. for(var i in list) {
  674. if(str.indexOf(list[i].id) == -1) {
  675. newArray.push(list[i]);
  676. }
  677. }
  678. for(var i in list) {
  679. if(str.indexOf(list[i].id) == -1) {
  680. if(list[i].subordinateType == 0){
  681. assets.push(list[i])
  682. } else {
  683. produce.push(list[i])
  684. }
  685. }
  686. }
  687. this.charger = newArray;
  688. this.assets = assets;
  689. this.produce = produce;
  690. },
  691. //提交
  692. addSubmit() {
  693. this.$refs.editForm.validate((valid) => {
  694. if (valid) {
  695. var cId = "",
  696. cName = "",
  697. modelIds = "",
  698. userIds = "";
  699. for(var i in this.editForm.customerCompany){
  700. if(cId.indexOf(this.editForm.customerCompany[i].id) == -1){
  701. cId += this.editForm.customerCompany[i].id + ",";
  702. cName += this.editForm.customerCompany[i].companyName + ",";
  703. }
  704. }
  705. cId = cId.substring(0,cId.length-1);
  706. cName = cName.substring(0,cName.length-1);
  707. for(var i in this.editForm.modelIds){
  708. modelIds += this.editForm.modelIds[i].id + ","
  709. }
  710. modelIds = modelIds.substring(0,modelIds.length-1);
  711. // for(var i in this.editForm.assets){
  712. // if(i == this.editForm.assets.length -1){
  713. // userIds += this.editForm.assets[i]
  714. // } else {
  715. // userIds += this.editForm.assets[i] + ","
  716. // }
  717. // }
  718. // if(userIds != "" && this.editForm.produce.length != 0){
  719. // userIds += ","
  720. // }
  721. // for(var i in this.editForm.produce){
  722. // if(i == this.editForm.produce.length -1){
  723. // userIds += this.editForm.produce[i]
  724. // } else {
  725. // userIds += this.editForm.produce[i] + ","
  726. // }
  727. // }
  728. for(var i in this.editForm.users) {
  729. if(i == this.editForm.users.length -1){
  730. userIds += this.editForm.users[i]
  731. } else {
  732. userIds += this.editForm.users[i] + ","
  733. }
  734. }
  735. this.editLoading = true;
  736. this.http.post(this.port.project.addProject, {
  737. id: this.editForm.id,
  738. projectName: this.editForm.projectName,
  739. customerCompanyIds: cId,
  740. customerCompanyNames: cName,
  741. manager: this.editForm.managerId.username,
  742. managerId: this.editForm.managerId.id,
  743. ownerApproverId: this.editForm.ownerApproverId,
  744. customerApproverId: this.editForm.customerApproverId,
  745. modelIds: modelIds,
  746. userIds: userIds,
  747. flag: 1
  748. } , res => {
  749. this.editLoading = false;
  750. this.editFormVisible = false;
  751. if (res.code == "ok") {
  752. this.$message({
  753. message: '修改成功',
  754. type: 'success'
  755. });
  756. this.getDetail();
  757. } else {
  758. this.$message({
  759. message: res.msg,
  760. type: 'error'
  761. });
  762. }
  763. }, error => {
  764. this.editLoading = false;
  765. this.editFormVisible = false;
  766. this.$message({
  767. message: error,
  768. type: 'error'
  769. });
  770. })
  771. }
  772. });
  773. },
  774. //打开新增人员
  775. addStaff() {
  776. this.addFormVisible = true;
  777. this.addForm = {
  778. parentId: this.user.id,
  779. username: '',
  780. account: '',
  781. companyId: '',
  782. roleName: '',
  783. projectIds: this.detailId,
  784. flag: 0
  785. };
  786. },
  787. addPeople(i) {
  788. this.$refs.addForm.validate((valid) => {
  789. if (valid) {
  790. if(i == 0){
  791. this.addLoading = true;
  792. }
  793. this.http.post(this.port.project.addUser, this.addForm , res => {
  794. if(i == 0){ this.addLoading = false; }
  795. else { this.$refs.addForm.resetFields();this.addForm.roleName = "" }
  796. if (res.code == "ok") {
  797. if(i == 0){ this.addFormVisible = false; }
  798. this.getStaff();
  799. this.$message({
  800. message: '创建成功',
  801. type: 'success'
  802. });
  803. } else {
  804. this.$message({
  805. message: res.msg,
  806. type: 'error'
  807. });
  808. }
  809. }, error => {
  810. if(i == 0){ this.addLoading = false;this.addFormVisible = false; }
  811. else { this.$refs.addForm.resetFields();this.addForm.roleName = "" }
  812. this.$message({
  813. message: error,
  814. type: 'error'
  815. });
  816. })
  817. }
  818. });
  819. },
  820. //上传
  821. uploadFile(params) {
  822. this.upLoading = true;
  823. var fileObj = params.file;
  824. var form = new FormData();
  825. form.append("projectId", this.proDetail.id);
  826. form.append("file", fileObj);
  827. this.http.uploadFile(this.port.project.uploadFile, form , res => {
  828. this.upLoading = false;
  829. this.$refs.upload.clearFiles();
  830. if (res.code == "ok") {
  831. this.$message({
  832. message: '上传成功',
  833. type: 'success'
  834. });
  835. this.getFileList();
  836. this.getOperList();
  837. } else {
  838. this.$message({
  839. message: res.msg,
  840. type: 'error'
  841. });
  842. }
  843. }, error => {
  844. this.upLoading = false;
  845. this.$refs.upload.clearFiles();
  846. this.$message({
  847. message: error,
  848. type: 'error'
  849. });
  850. })
  851. },
  852. //下载
  853. dowloadFile(id) {
  854. this.http.post(this.port.project.dowloadFile, {
  855. id: id
  856. }, res => {
  857. this.getOperList();
  858. }, error => {
  859. })
  860. },
  861. //删除上传文件
  862. fileDel(id) {
  863. this.$confirm('确认删除该文档吗?', '提示', {
  864. type: 'warning'
  865. }).then(() => {
  866. this.http.post(this.port.project.delFile, {
  867. id: id
  868. }, res => {
  869. if (res.code == "ok") {
  870. this.$message({
  871. message: '删除成功',
  872. type: 'success'
  873. });
  874. this.getFileList();
  875. this.getOperList();
  876. } else {
  877. this.$message({
  878. message: res.msg,
  879. type: 'error'
  880. });
  881. }
  882. }, error => {
  883. this.$message({
  884. message: error,
  885. type: 'error'
  886. });
  887. })
  888. });
  889. },
  890. },
  891. created() {
  892. let height = window.innerHeight;
  893. this.allDetail.height = height - 170 + "px";
  894. const that = this;
  895. window.onresize = function temp() {
  896. that.allDetail.height = window.innerHeight - 170;
  897. };
  898. },
  899. mounted() {
  900. this.getDetail();
  901. this.getFileList();
  902. this.getOperList();
  903. }
  904. };
  905. </script>
  906. <style scoped>
  907. a {
  908. text-decoration:none;
  909. color: #333;
  910. }
  911. .allDetail {
  912. overflow-y: auto;
  913. }
  914. .toolbar .el-form-item {
  915. font-size: 14px;
  916. vertical-align: middle;
  917. }
  918. .back {
  919. font-size:16px;
  920. }
  921. .divLine {
  922. width: 2px;
  923. background: #c3c3c3;
  924. height: 100%;
  925. }
  926. .projectTitle {
  927. font-size: 18px;
  928. color: #333;
  929. }
  930. .title {
  931. padding-left: 10px;
  932. padding-bottom: 0px;
  933. margin: 20px 0;
  934. font-size: 16px;
  935. line-height: 24px;
  936. border-left: 1px #20a0ff solid;
  937. position: relative;
  938. }
  939. .upload-demo {
  940. position: absolute;
  941. right: 0;
  942. top: -5px;
  943. }
  944. .editDetail {
  945. margin-left: 10px;
  946. color:#20a0ff;
  947. cursor: pointer;
  948. }
  949. .info {
  950. color: grey;
  951. }
  952. .model {
  953. cursor: pointer;
  954. color:#20a0ff;
  955. }
  956. .main {
  957. padding-left: 10px;
  958. }
  959. .detail {
  960. margin-bottom: 20px;
  961. }
  962. .el-collapse {
  963. border: none;
  964. }
  965. </style>