projectDetail.vue 43 KB

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