project.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true" :model="filters">
  6. <el-form-item>
  7. <el-input v-model="filters.keyName" placeholder="请输入项目名称"></el-input>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button type="primary" v-on:click="getProject">查询</el-button>
  11. </el-form-item>
  12. <el-form-item style="float:right;" v-if="user.parentId == 1 && user.subordinateType == 0">
  13. <el-button type="primary" @click="handleAdd">新增</el-button>
  14. </el-form-item>
  15. </el-form>
  16. </el-col>
  17. <!--列表-->
  18. <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;">
  19. <el-table-column type="index" width="60">
  20. </el-table-column>
  21. <el-table-column prop="projectName" label="项目名称" width="250" sortable>
  22. <template slot-scope="scope">
  23. <el-link :underline="false" type="primary" @click="toDetail(scope.row)">{{scope.row.projectName}}</el-link>
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="ownerCompanyName" label="资产方公司" sortable>
  27. </el-table-column>
  28. <el-table-column prop="customCompaniesStr" label="生产方公司" width="450">
  29. </el-table-column>
  30. <el-table-column prop="manager" label="项目经理" width="100" align="center" sortable>
  31. </el-table-column>
  32. <el-table-column prop="indate" label="创建时间" width="250" align="center" sortable>
  33. </el-table-column>
  34. <!-- <el-table-column label="操作" width="250" align="center">
  35. <template slot-scope="scope">
  36. <el-button size="small" type="primary" @click="toDetail(scope.row.id)">详情</el-button>
  37. <el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  38. <el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
  39. </template>
  40. </el-table-column> -->
  41. </el-table>
  42. <!--工具条-->
  43. <el-col :span="24" class="toolbar">
  44. <el-pagination
  45. @size-change="handleSizeChange"
  46. @current-change="handleCurrentChange"
  47. :page-sizes="[20 , 50 , 80 , 100]"
  48. :page-size="20"
  49. layout="total, sizes, prev, pager, next"
  50. :total="total"
  51. style="float:right;">
  52. </el-pagination>
  53. </el-col>
  54. <!--新增界面-->
  55. <el-dialog title="新增项目" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass='customWidth'>
  56. <el-form :model="addForm" label-width="120px" :rules="formRules" ref="addForm">
  57. <el-col :span="24">
  58. <el-form-item label="项目名称" prop="projectName">
  59. <el-input v-model="addForm.projectName" autocomplete="off" placeholder="请输入项目名称" style="width:510px"></el-input>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="24">
  63. <el-form-item label="项目模具" prop="mold">
  64. <el-select v-model="addForm.mold" @change="companyChange" clearable filterable multiple placeholder="请选择项目模具" value-key='id' style="width:510px">
  65. <el-option v-for="item in molds" :key="item.id" :label="item.modelName" :value="item">
  66. <span style="float: left">{{ item.modelName }}</span>
  67. <span style="float: right; color: #8492a6; font-size: 6px;margin-right:17px;">{{ item.produceCompany }}</span>
  68. </el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="24">
  73. <el-form-item label="项目经理" prop="managerId">
  74. <el-select v-model="addForm.managerId" clearable filterable placeholder="请选择项目经理" value-key='id' style="width:510px">
  75. <!-- <el-option v-for="item in charger" :key="item.id" :label="item.username" :value="item">
  76. </el-option> -->
  77. <el-option v-for="item in charger" :key="item.id" :label="item.username" :value="item">
  78. <span style="float: left">{{ item.username }}</span>
  79. <span style="float: right; color: #8492a6; font-size: 13px;">{{ item.companyName }}</span>
  80. </el-option>
  81. </el-select>
  82. </el-form-item>
  83. </el-col>
  84. </el-form>
  85. <div slot="footer" class="dialog-footer">
  86. <el-button @click.native="addFormVisible = false">取消</el-button>
  87. <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
  88. </div>
  89. </el-dialog>
  90. </section>
  91. </template>
  92. <script>
  93. import util from '../../common/js/util'
  94. export default {
  95. data() {
  96. return {
  97. filters: {
  98. keyName: ''
  99. },
  100. user: JSON.parse(sessionStorage.getItem('user')),
  101. charger: [],
  102. molds: [],
  103. list: [],
  104. total: 0,
  105. page: 1,
  106. size: 20,
  107. listLoading: false,
  108. tableHeight: 0,
  109. formRules: {
  110. projectName: [
  111. { required: true, message: '请输入项目名称', trigger: 'blur' }
  112. ],
  113. mold: [
  114. { required: true, message: '请选择项目模具', trigger: ['blur','change'] }
  115. ],
  116. managerId: [
  117. { required: true, message: '请选择项目经理', trigger: ['blur','change'] }
  118. ]
  119. },
  120. addFormVisible: false, //新增界面是否显示
  121. addLoading: false,
  122. //新增界面数据
  123. addForm: {
  124. projectName: '',
  125. mold: [],
  126. managerId: ''
  127. }
  128. }
  129. },
  130. methods: {
  131. //获取基础数据
  132. getMsg(){
  133. this.http.post(this.port.project.getUserById, {
  134. companyIds: this.user.companyId,
  135. id: this.user.id
  136. } , res => {
  137. if (res.code == "ok") {
  138. this.charger = res.data;
  139. } else {
  140. this.$message({
  141. message: res.msg,
  142. type: 'error'
  143. });
  144. }
  145. }, error => {
  146. this.$message({
  147. message: error,
  148. type: 'error'
  149. });
  150. })
  151. //获取模具
  152. this.getMoulds();
  153. },
  154. //获取模具
  155. getMoulds(){
  156. this.http.post(this.port.mold.modelList, {
  157. parentId: this.user.parentId,
  158. id: this.user.id
  159. }, res => {
  160. if (res.code == "ok") {
  161. this.molds = res.data;
  162. } else {
  163. this.$message({
  164. message: res.msg,
  165. type: 'error'
  166. });
  167. }
  168. }, error => {
  169. this.$message({
  170. message: error,
  171. type: 'error'
  172. });
  173. })
  174. },
  175. //分页
  176. handleCurrentChange(val) {
  177. this.page = val;
  178. this.getProject();
  179. },
  180. handleSizeChange(val) {
  181. this.size = val;
  182. this.getProject();
  183. },
  184. //获取项目列表
  185. getProject() {
  186. this.listLoading = true;
  187. this.http.post(this.port.project.projectList, {
  188. keyName: this.filters.keyName,
  189. pageNum: this.page,
  190. pageSize: this.size,
  191. }, res => {
  192. this.listLoading = false;
  193. if (res.code == "ok") {
  194. var list = res.data.list;
  195. for(var i in list){
  196. var customCompaniesStr = "";
  197. for(var j in list[i].customCompanies){
  198. if(j == list[i].customCompanies.length -1){
  199. customCompaniesStr += list[i].customCompanies[j].companyName;
  200. } else {
  201. customCompaniesStr += list[i].customCompanies[j].companyName + "、";
  202. }
  203. }
  204. list[i].customCompaniesStr = customCompaniesStr;
  205. }
  206. this.list = list;
  207. this.total = res.data.total;
  208. } else {
  209. this.$message({
  210. message: res.msg,
  211. type: 'error'
  212. });
  213. }
  214. }, error => {
  215. this.listLoading = false;
  216. this.$message({
  217. message: error,
  218. type: 'error'
  219. });
  220. })
  221. },
  222. //详情
  223. toDetail(row) {
  224. this.$router.push('/project/' + row.id);
  225. },
  226. //选择公司切换人员
  227. companyChange() {
  228. var param = {} ,
  229. str = this.user.companyId;
  230. for(var i in this.addForm.mold){
  231. str += "," + this.addForm.mold[i].produceCompanyId;
  232. }
  233. param.companyIds = str;
  234. param.id = this.user.id
  235. this.http.post(this.port.project.getUserById, param , res => {
  236. if (res.code == "ok") {
  237. this.charger = res.data;
  238. } else {
  239. this.$message({
  240. message: res.msg,
  241. type: 'error'
  242. });
  243. }
  244. }, error => {
  245. this.$message({
  246. message: error,
  247. type: 'error'
  248. });
  249. })
  250. },
  251. //显示新增界面
  252. handleAdd() {
  253. //重新获取一下模具
  254. this.getMoulds();
  255. this.addFormVisible = true;
  256. this.addForm = {
  257. projectName: '',
  258. mold: [],
  259. managerId: ''
  260. };
  261. },
  262. //新增
  263. addSubmit() {
  264. this.$refs.addForm.validate((valid) => {
  265. if (valid) {
  266. var cId = "",
  267. cName = "",
  268. mId = "";
  269. for(var i in this.addForm.mold){
  270. if(cId.indexOf(this.addForm.mold[i].produceCompanyId) == -1){
  271. cId += this.addForm.mold[i].produceCompanyId + ",";
  272. cName += this.addForm.mold[i].produceCompanyName + ",";
  273. }
  274. mId += this.addForm.mold[i].id + ","
  275. }
  276. cId = cId.substring(0,cId.length-1);
  277. cName = cName.substring(0,cName.length-1);
  278. mId = mId.substring(0,mId.length-1);
  279. this.addLoading = true;
  280. this.http.post(this.port.project.addProject, {
  281. projectName: this.addForm.projectName,
  282. customerCompanyIds: cId,
  283. customerCompanyNames: cName,
  284. manager: this.addForm.managerId.username,
  285. managerId: this.addForm.managerId.id,
  286. modelIds: mId,
  287. flag: 0
  288. } , res => {
  289. this.addLoading = false;
  290. if (res.code == "ok") {
  291. this.addFormVisible = false;
  292. this.$message({
  293. message: '创建成功',
  294. type: 'success'
  295. });
  296. this.getProject();
  297. } else {
  298. this.$message({
  299. message: res.msg,
  300. type: 'error'
  301. });
  302. }
  303. }, error => {
  304. this.addLoading = false;
  305. this.addFormVisible = false;
  306. this.$message({
  307. message: error,
  308. type: 'error'
  309. });
  310. })
  311. }
  312. });
  313. },
  314. },
  315. created() {
  316. let height = window.innerHeight;
  317. this.tableHeight = height - 210;
  318. const that = this;
  319. window.onresize = function temp() {
  320. that.tableHeight = window.innerHeight - 210;
  321. };
  322. },
  323. mounted() {
  324. this.getMsg();
  325. this.getProject();
  326. }
  327. }
  328. </script>
  329. <style scoped>
  330. </style>