list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <basic-container>
  3. <div>
  4. <div class="pd-b-20 border-grey-b">
  5. <span class="mg-r-10">选择项目名称</span>
  6. <el-select
  7. v-model="projectId"
  8. @change="projectChange"
  9. placeholder="请选择"
  10. >
  11. <el-option
  12. v-for="item in projectList"
  13. :key="item.id"
  14. :label="item.projectAlias"
  15. :value="item.id"
  16. ></el-option>
  17. </el-select>
  18. </div>
  19. <div class="pd-t-20">
  20. <el-row
  21. :gutter="20"
  22. style="height:calc(100vh - 290px)"
  23. >
  24. <el-col
  25. :span="6"
  26. v-for="(item,index) in projectPageList"
  27. :key="item.id"
  28. style="height:20%;"
  29. class="mg-b-20 box-size-bb"
  30. >
  31. <el-card
  32. @click.native="projectClick(item)"
  33. class="box-card h-100p flex flex-center project_name"
  34. :class="getBg(index)"
  35. >
  36. {{item.projectAlias}}
  37. </el-card>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. <div>
  42. <el-pagination
  43. layout="prev, pager, next"
  44. class="text-align-c"
  45. @current-change="handleCurrentChange"
  46. :current-page.sync="page.currentPage"
  47. :total="page.total"
  48. :page-size="page.pageSize"
  49. >
  50. </el-pagination>
  51. </div>
  52. </div>
  53. <el-dialog
  54. title="项目信息"
  55. :visible.sync="projectVisible"
  56. width="900px"
  57. append-to-body
  58. >
  59. <div class="mg-b-10"><span class="flex1 mg-r-20">{{curProjiect.projectName}}</span></div>
  60. <div class="flex jc-sb pd-b-10">
  61. <span></span>
  62. <div>
  63. <el-button
  64. size="small"
  65. @click="measureTree"
  66. style="background-color: #626aef;color: white;"
  67. >计量管理</el-button>
  68. <el-button
  69. size="small"
  70. @click="splitTree"
  71. type="success"
  72. >征拆划分</el-button>
  73. <el-button
  74. size="small"
  75. @click="testTree"
  76. type="success"
  77. >试验划分</el-button>
  78. <el-button
  79. size="small"
  80. @click="editTree"
  81. type="success"
  82. >WBS树管理</el-button>
  83. <el-button
  84. size="small"
  85. @click="editLogTree"
  86. type="success"
  87. >日志WBS树管理</el-button>
  88. <el-button
  89. size="small"
  90. @click="editProject"
  91. type="primary"
  92. >编辑项目信息</el-button>
  93. <el-button
  94. size="small"
  95. @click="addContract"
  96. type="info"
  97. >创建新合同段</el-button>
  98. <el-button
  99. size="small"
  100. @click="dellProject"
  101. type="danger"
  102. >删除项目</el-button>
  103. <el-button
  104. style="margin-top: 10px;"
  105. size="small"
  106. @click="projectVisible = false"
  107. >返回</el-button>
  108. </div>
  109. </div>
  110. <div
  111. style="height:400px;overflow: auto;"
  112. v-if="contractList.length > 0"
  113. >
  114. <el-card
  115. shadow="never"
  116. v-for="(item,index) in contractList"
  117. :key="item.id"
  118. >
  119. <div class="flex jc-sb">
  120. <div class="flex jc-al-c flex1">
  121. <el-avatar
  122. :size="50"
  123. :class="getAvatarBg(item.contractType)"
  124. >{{getFont(item.contractType)}}</el-avatar>
  125. <span class="mg-l-10 flex1 mg-r-10">{{item.contractName}}</span>
  126. </div>
  127. <div class="flex jc-al-c">
  128. <el-link
  129. type="primary"
  130. @click="editContract(item)"
  131. >编辑合同段信息</el-link>
  132. <el-link
  133. type="primary"
  134. class="mg-l-10"
  135. v-if="item.contractType==1"
  136. @click="contractDetail(item,'2',item.contractType)"
  137. >分配WBS</el-link>
  138. <el-link
  139. type="primary"
  140. class="mg-l-10"
  141. @click="delContract(item,index)"
  142. >删除</el-link>
  143. </div>
  144. </div>
  145. </el-card>
  146. </div>
  147. <div
  148. class="text-align-c pd-t-20"
  149. v-else
  150. >
  151. 暂无合同段,请先创建合同段
  152. </div>
  153. </el-dialog>
  154. </basic-container>
  155. </template>
  156. <script>
  157. import { getProjectList, removeProject } from "@/api/manager/projectinfo";
  158. import { findContractByProjectId, removeContractInfo } from "@/api/manager/contractinfo";
  159. // import {getDictionary} from "@/api/system/dict";
  160. import { mapGetters } from "vuex";
  161. import { getStore, setStore } from "@/util/store";
  162. export default {
  163. data () {
  164. return {
  165. projectId: '',
  166. curProjiect: {},
  167. projectList: [],
  168. projectPageList: [],
  169. projectVisible: false,
  170. contractList: [],
  171. page: {
  172. currentPage: 1,
  173. pageSize: 16,
  174. total: 0
  175. }
  176. }
  177. },
  178. computed: {
  179. ...mapGetters(["userInfo"]),
  180. },
  181. created () {
  182. this.init();
  183. //console.log(this.userInfo)
  184. },
  185. methods: {
  186. init () {
  187. this.getProjectList();
  188. this.getProjectPageList();
  189. },
  190. getProjectList () {
  191. getProjectList(1, 999).then((res) => {
  192. this.projectList = res.data.data.records;
  193. })
  194. },
  195. getProjectPageList () {
  196. getProjectList(this.page.currentPage, this.page.pageSize).then((res) => {
  197. this.projectPageList = res.data.data.records;
  198. this.page.total = res.data.data.total;
  199. })
  200. },
  201. projectClick (item) {
  202. this.curProjiect = item;
  203. findContractByProjectId(this.curProjiect.id).then((res) => {
  204. this.contractList = res.data.data;
  205. })
  206. this.projectVisible = true;
  207. },
  208. handleCurrentChange (val) {
  209. this.getProjectPageList();
  210. this.page.currentPage = val;
  211. },
  212. projectChange (id) {
  213. for (let i = 0; i < this.projectList.length; i++) {
  214. if (id == this.projectList[i].id) {
  215. this.curProjiect = this.projectList[i];
  216. findContractByProjectId(this.curProjiect.id).then((res) => {
  217. this.contractList = res.data.data;
  218. })
  219. this.projectVisible = true;
  220. return;
  221. }
  222. }
  223. },
  224. addContract () {
  225. this.$router.push({
  226. path: '/contract/detail',
  227. query: { pid: this.curProjiect.id }
  228. });
  229. },
  230. editContract (item) {
  231. this.$router.push({
  232. path: '/contract/detail',
  233. query: {
  234. pid: item.pid,
  235. cid: item.id,
  236. contractType: item.contractType
  237. }
  238. });
  239. },
  240. editProject () {
  241. this.$router.push({
  242. path: '/manager/projectinfo/detail',
  243. query: {
  244. id: this.curProjiect.id
  245. }
  246. });
  247. },
  248. contractDetail (item, type, contractType) {
  249. this.$router.push({
  250. path: '/contract/detail',
  251. query: {
  252. pid: item.pid,
  253. cid: item.id,
  254. type,
  255. contractType
  256. }
  257. })
  258. },
  259. testTree () {
  260. this.$router.push({
  261. path: '/project/tree',
  262. query: {
  263. pid: this.curProjiect.id,
  264. wbsid: this.curProjiect.referenceWbsTemplateIdTrial,
  265. projectName:this.curProjiect.projectName,
  266. type: 2
  267. }
  268. });
  269. },
  270. splitTree () {
  271. this.$router.push({
  272. path: '/project/tree',
  273. query: {
  274. pid: this.curProjiect.id,
  275. wbsid: this.curProjiect.referenceWbsTemplateIdLar,
  276. projectName:this.curProjiect.projectName,
  277. type: 5
  278. }
  279. });
  280. },
  281. measureTree(){
  282. this.$router.push({
  283. path: '/project/tree',
  284. query: {
  285. pid: this.curProjiect.id,
  286. wbsid: this.curProjiect.referenceWbsTemplateIdMeter,
  287. projectName:this.curProjiect.projectName,
  288. type: 3
  289. }
  290. });
  291. },
  292. editTree () {
  293. this.$router.push({
  294. path: '/project/tree',
  295. query: {
  296. pid: this.curProjiect.id,
  297. wbsid: this.curProjiect.referenceWbsTemplateId,
  298. projectName:this.curProjiect.projectName
  299. }
  300. });
  301. },
  302. editLogTree () {
  303. this.$router.push({
  304. path: '/project/tree',
  305. query: {
  306. pid: this.curProjiect.id,
  307. wbsid: this.curProjiect.referenceLogWbsTemplateId,
  308. projectName:this.curProjiect.projectName,
  309. type: 4
  310. }
  311. });
  312. },
  313. delContract (item, index) {
  314. this.$confirm('是否删除【' + item.contractName + '】?', '提示', {
  315. confirmButtonText: '确定',
  316. cancelButtonText: '取消',
  317. type: 'warning'
  318. }).then(() => {
  319. removeContractInfo(item.id).then(() => {
  320. this.$message({
  321. type: "success",
  322. message: "删除成功!"
  323. });
  324. this.contractList.splice(index, 1);
  325. })
  326. })
  327. },
  328. dellProject () {
  329. if (this.contractList.length) {
  330. this.$message({
  331. type: "warning",
  332. message: "只能删除下面无合同段的项目!"
  333. });
  334. return;
  335. }
  336. this.$confirm('是否删除【' + this.curProjiect.projectName + '】?', '提示', {
  337. confirmButtonText: '确定',
  338. cancelButtonText: '取消',
  339. type: 'warning'
  340. }).then(() => {
  341. removeProject(this.curProjiect.id).then(() => {
  342. this.$message({
  343. type: "success",
  344. message: "删除成功!"
  345. });
  346. //删除后当前列表为空,且不是第一页,往前翻一页
  347. if(this.projectPageList.length == 1 && this.page.currentPage >1){
  348. this.page.currentPage--;
  349. }
  350. this.getProjectPageList();
  351. this.projectVisible = false;
  352. })
  353. })
  354. },
  355. getFont (type) {
  356. if (type == 1) {
  357. return '施';
  358. } else if (type == 2) {
  359. return '监';
  360. } else if (type == 3) {
  361. return '业';
  362. }
  363. return '';
  364. },
  365. getAvatarBg (type) {
  366. if (type == 1) {
  367. return { 'abg1': true };
  368. } else if (type == 2) {
  369. return { 'abg2': true };
  370. } else if (type == 3) {
  371. return { 'abg3': true };
  372. }
  373. return {};
  374. },
  375. getBg (index) {
  376. let num = Math.trunc(index / 4);
  377. if ((num % 2) === 0) {//判定条件余数为0时为偶数
  378. return {
  379. 'bg1': true
  380. }
  381. } else {
  382. return {
  383. 'bg2': true
  384. }
  385. }
  386. },
  387. wbsManage () {//wbs树管理按钮
  388. this.$router.push('/manager/privateWBS/' + 111)
  389. },
  390. }
  391. };
  392. </script>
  393. <style scoped lang="scss">
  394. .project_name {
  395. font-size: 20px;
  396. cursor: pointer;
  397. }
  398. .bg1 {
  399. background-color: rgb(127, 164, 221);
  400. border-color: rgb(187, 187, 187);
  401. box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 6px 0px;
  402. }
  403. .bg2 {
  404. background-color: rgb(239, 240, 229);
  405. border-color: rgb(187, 187, 187);
  406. box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 6px 0px;
  407. }
  408. .abg1 {
  409. background-color: rgb(42, 155, 121);
  410. }
  411. .abg2 {
  412. background-color: rgb(155, 108, 42);
  413. }
  414. .abg3 {
  415. background-color: rgb(42, 53, 155);
  416. }
  417. </style>