projectDetail.vue 47 KB

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