project.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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" 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-form>
  73. <div slot="footer" class="dialog-footer">
  74. <el-button @click.native="addFormVisible = false">取消</el-button>
  75. <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
  76. </div>
  77. </el-dialog>
  78. </section>
  79. </template>
  80. <script>
  81. import util from '../../common/js/util'
  82. export default {
  83. data() {
  84. return {
  85. filters: {
  86. keyName: ''
  87. },
  88. user: JSON.parse(sessionStorage.getItem('user')),
  89. company:[],
  90. charger: [],
  91. molds: [],
  92. list: [],
  93. total: 0,
  94. page: 1,
  95. size: 20,
  96. listLoading: false,
  97. tableHeight: 0,
  98. formRules: {
  99. projectName: [
  100. { required: true, message: '请输入项目名称', trigger: 'blur' }
  101. ],
  102. mold: [
  103. { required: true, message: '请选择项目模具', trigger: ['blur','change'] }
  104. ],
  105. managerId: [
  106. { required: true, message: '请选择项目经理', trigger: ['blur','change'] }
  107. ]
  108. },
  109. addFormVisible: false,//新增界面是否显示
  110. addLoading: false,
  111. //新增界面数据
  112. addForm: {
  113. projectName: '',
  114. mold: [],
  115. managerId: ''
  116. }
  117. }
  118. },
  119. methods: {
  120. // 获取基础数据
  121. getMsg(){
  122. this.http.post(this.port.project.getUserById, {
  123. companyIds: this.user.companyId,
  124. id: this.user.id
  125. } , res => {
  126. if (res.code == "ok") {
  127. this.charger = res.data;
  128. } else {
  129. this.$message({
  130. message: res.msg,
  131. type: 'error'
  132. });
  133. }
  134. }, error => {
  135. this.$message({
  136. message: error,
  137. type: 'error'
  138. });
  139. })
  140. this.http.post(this.port.base.addCompanyListToProject, {
  141. parentId: this.user.parentId,
  142. id: this.user.id
  143. }, res => {
  144. if (res.code == "ok") {
  145. var list = res.data , array = [];
  146. for(var i in list){
  147. if(list[i].id != this.user.companyId){
  148. array.push(list[i])
  149. }
  150. }
  151. this.company = array;
  152. } else {
  153. this.$message({
  154. message: res.msg,
  155. type: 'error'
  156. });
  157. }
  158. }, error => {
  159. this.$message({
  160. message: error,
  161. type: 'error'
  162. });
  163. })
  164. // 获取模具
  165. this.http.post(this.port.mold.modelList, {
  166. parentId: this.user.parentId,
  167. id: this.user.id
  168. }, res => {
  169. if (res.code == "ok") {
  170. this.molds = res.data;
  171. } else {
  172. this.$message({
  173. message: res.msg,
  174. type: 'error'
  175. });
  176. }
  177. }, error => {
  178. this.$message({
  179. message: error,
  180. type: 'error'
  181. });
  182. })
  183. },
  184. //分页
  185. handleCurrentChange(val) {
  186. this.page = val;
  187. this.getProject();
  188. },
  189. handleSizeChange(val) {
  190. this.size = val;
  191. this.getProject();
  192. },
  193. //获取项目列表
  194. getProject() {
  195. this.listLoading = true;
  196. this.http.post(this.port.project.projectList, {
  197. keyName: this.filters.keyName,
  198. pageNum: this.page,
  199. pageSize: this.size,
  200. }, res => {
  201. this.listLoading = false;
  202. if (res.code == "ok") {
  203. var list = res.data.list;
  204. for(var i in list){
  205. var customCompaniesStr = "";
  206. for(var j in list[i].customCompanies){
  207. if(j == list[i].customCompanies.length -1){
  208. customCompaniesStr += list[i].customCompanies[j].companyName;
  209. } else {
  210. customCompaniesStr += list[i].customCompanies[j].companyName + "、";
  211. }
  212. }
  213. list[i].customCompaniesStr = customCompaniesStr;
  214. }
  215. this.list = list;
  216. this.total = res.data.total;
  217. } else {
  218. this.$message({
  219. message: res.msg,
  220. type: 'error'
  221. });
  222. }
  223. }, error => {
  224. this.listLoading = false;
  225. this.$message({
  226. message: error,
  227. type: 'error'
  228. });
  229. })
  230. },
  231. //详情
  232. toDetail(row) {
  233. this.$router.push('/project/' + row.id);
  234. },
  235. //选择公司切换人员
  236. companyChange() {
  237. var param = {} ,
  238. str = this.user.companyId;
  239. for(var i in this.addForm.molds){
  240. str += "," + this.addForm.molds[i].companyId;
  241. }
  242. param.companyIds = str;
  243. param.id = this.user.id
  244. this.http.post(this.port.project.getUserById, param , res => {
  245. if (res.code == "ok") {
  246. this.charger = res.data;
  247. } else {
  248. this.$message({
  249. message: res.msg,
  250. type: 'error'
  251. });
  252. }
  253. }, error => {
  254. this.$message({
  255. message: error,
  256. type: 'error'
  257. });
  258. })
  259. },
  260. //显示新增界面
  261. handleAdd() {
  262. this.addFormVisible = true;
  263. this.addForm = {
  264. projectName: '',
  265. mold: [],
  266. managerId: ''
  267. };
  268. },
  269. //新增
  270. addSubmit() {
  271. this.$refs.addForm.validate((valid) => {
  272. if (valid) {
  273. var cId = "",
  274. cName = "",
  275. mId = "";
  276. for(var i in this.addForm.mold){
  277. cId += this.addForm.mold[i].produceCompanyId + ",";
  278. cName += this.addForm.mold[i].produceCompany + ",";
  279. mId += this.addForm.mold[i].id + ","
  280. }
  281. cId = cId.substring(0,cId.length-1);
  282. cName = cName.substring(0,cName.length-1);
  283. mId = mId.substring(0,mId.length-1);
  284. this.addLoading = true;
  285. this.http.post(this.port.project.addProject, {
  286. projectName: this.addForm.projectName,
  287. customerCompanyIds: cId,
  288. customerCompanyNames: cName,
  289. manager: this.addForm.managerId.username,
  290. managerId: this.addForm.managerId.id,
  291. modelIds: mId,
  292. flag: 0
  293. } , res => {
  294. this.addLoading = false;
  295. if (res.code == "ok") {
  296. this.addFormVisible = false;
  297. this.$message({
  298. message: '创建成功',
  299. type: 'success'
  300. });
  301. this.getProject();
  302. } else {
  303. this.$message({
  304. message: res.msg,
  305. type: 'error'
  306. });
  307. }
  308. }, error => {
  309. this.addLoading = false;
  310. this.addFormVisible = false;
  311. this.$message({
  312. message: error,
  313. type: 'error'
  314. });
  315. })
  316. }
  317. });
  318. },
  319. },
  320. created() {
  321. let height = window.innerHeight;
  322. this.tableHeight = height - 210;
  323. const that = this;
  324. window.onresize = function temp() {
  325. that.tableHeight = window.innerHeight - 210;
  326. };
  327. },
  328. mounted() {
  329. this.getMsg();
  330. this.getProject();
  331. }
  332. }
  333. </script>
  334. <style scoped>
  335. </style>