projectDetail.vue 44 KB

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