list.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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="800px"
  57. append-to-body
  58. >
  59. <div class="flex jc-sb pd-b-10">
  60. <span class="flex1 mg-r-20">{{curProjiect.projectName}}</span>
  61. <div>
  62. <el-button
  63. size="small"
  64. @click="editTree"
  65. type="success"
  66. >WBS树管理</el-button>
  67. <el-button
  68. size="small"
  69. @click="editProject"
  70. type="primary"
  71. >编辑项目信息</el-button>
  72. <el-button
  73. size="small"
  74. @click="addContract"
  75. type="info"
  76. >创建新合同段</el-button>
  77. <el-button
  78. size="small"
  79. @click="dellProject"
  80. type="danger"
  81. >删除项目</el-button>
  82. <el-button
  83. size="small"
  84. @click="projectVisible = false"
  85. >返回</el-button>
  86. </div>
  87. </div>
  88. <div
  89. style="height:400px;overflow: auto;"
  90. v-if="contractList.length > 0"
  91. >
  92. <el-card
  93. shadow="never"
  94. v-for="(item,index) in contractList"
  95. :key="item.id"
  96. >
  97. <div class="flex jc-sb">
  98. <div class="flex jc-al-c flex1">
  99. <el-avatar
  100. :size="50"
  101. :class="getAvatarBg(item.contractType)"
  102. >{{getFont(item.contractType)}}</el-avatar>
  103. <span class="mg-l-10 flex1 mg-r-10">{{item.contractName}}</span>
  104. </div>
  105. <div class="flex jc-al-c">
  106. <el-link
  107. type="primary"
  108. @click="editContract(item)"
  109. >编辑合同段信息</el-link>
  110. <el-link
  111. type="primary"
  112. class="mg-l-10"
  113. @click="contractDetail(item,'2')"
  114. >分配WBS</el-link>
  115. <el-link
  116. type="primary"
  117. class="mg-l-10"
  118. @click="contractDetail(item,'3')"
  119. >分配项目人员</el-link>
  120. <el-link
  121. type="primary"
  122. class="mg-l-10"
  123. @click="delContract(item,index)"
  124. >删除</el-link>
  125. </div>
  126. </div>
  127. </el-card>
  128. </div>
  129. <div
  130. class="text-align-c pd-t-20"
  131. v-else
  132. >
  133. 暂无合同段,请先创建合同段
  134. </div>
  135. </el-dialog>
  136. </basic-container>
  137. </template>
  138. <script>
  139. import { getProjectList, removeProject } from "@/api/manager/projectinfo";
  140. import { findContractByProjectId, removeContractInfo } from "@/api/manager/contractinfo";
  141. // import {getDictionary} from "@/api/system/dict";
  142. import { mapGetters } from "vuex";
  143. export default {
  144. data () {
  145. return {
  146. projectId: '',
  147. curProjiect: {},
  148. projectList: [],
  149. projectPageList: [],
  150. projectVisible: false,
  151. contractList: [],
  152. page: {
  153. currentPage: 1,
  154. pageSize: 16,
  155. total: 0
  156. }
  157. }
  158. },
  159. computed: {
  160. ...mapGetters(["userInfo"]),
  161. },
  162. created () {
  163. this.init();
  164. //console.log(this.userInfo)
  165. },
  166. methods: {
  167. init () {
  168. this.getProjectList();
  169. this.getProjectPageList();
  170. },
  171. getProjectList () {
  172. getProjectList(1, 999).then((res) => {
  173. this.projectList = res.data.data.records;
  174. })
  175. },
  176. getProjectPageList () {
  177. getProjectList(this.page.currentPage, this.page.pageSize).then((res) => {
  178. this.projectPageList = res.data.data.records;
  179. this.page.total = res.data.data.total;
  180. })
  181. },
  182. projectClick (item) {
  183. this.curProjiect = item;
  184. findContractByProjectId(this.curProjiect.id).then((res) => {
  185. this.contractList = res.data.data;
  186. })
  187. this.projectVisible = true;
  188. },
  189. handleCurrentChange (val) {
  190. this.getProjectPageList();
  191. this.page.currentPage = val;
  192. },
  193. projectChange (id) {
  194. for (let i = 0; i < this.projectList.length; i++) {
  195. if (id == this.projectList[i].id) {
  196. this.curProjiect = this.projectList[i];
  197. findContractByProjectId(this.curProjiect.id).then((res) => {
  198. this.contractList = res.data.data;
  199. })
  200. this.projectVisible = true;
  201. return;
  202. }
  203. }
  204. },
  205. addContract () {
  206. this.$router.push({
  207. path: '/contract/detail',
  208. query: { pid: this.curProjiect.id }
  209. });
  210. },
  211. editContract (item) {
  212. this.$router.push({
  213. path: '/contract/detail',
  214. query: {
  215. pid: item.pid,
  216. cid: item.id,
  217. }
  218. });
  219. },
  220. editProject () {
  221. this.$router.push({
  222. path: '/manager/projectinfo/detail',
  223. query: {
  224. id: this.curProjiect.id
  225. }
  226. });
  227. },
  228. contractDetail (item, type) {
  229. this.$router.push({
  230. path: '/contract/detail',
  231. query: {
  232. pid: item.pid,
  233. cid: item.id,
  234. type,
  235. }
  236. });
  237. },
  238. editTree () {
  239. this.$router.push({
  240. path: '/project/tree',
  241. query: {
  242. pid: this.curProjiect.id,
  243. wbsid: this.curProjiect.referenceWbsTemplateId
  244. }
  245. });
  246. },
  247. delContract (item, index) {
  248. this.$confirm('是否删除【' + item.contractName + '】?', '提示', {
  249. confirmButtonText: '确定',
  250. cancelButtonText: '取消',
  251. type: 'warning'
  252. }).then(() => {
  253. removeContractInfo(item.id).then(() => {
  254. this.$message({
  255. type: "success",
  256. message: "删除成功!"
  257. });
  258. this.contractList.splice(index, 1);
  259. })
  260. })
  261. },
  262. dellProject () {
  263. if (this.contractList.length) {
  264. this.$message({
  265. type: "warning",
  266. message: "只能删除下面无合同段的项目!"
  267. });
  268. return;
  269. }
  270. this.$confirm('是否删除【' + this.curProjiect.projectName + '】?', '提示', {
  271. confirmButtonText: '确定',
  272. cancelButtonText: '取消',
  273. type: 'warning'
  274. }).then(() => {
  275. removeProject(this.curProjiect.id).then(() => {
  276. this.$message({
  277. type: "success",
  278. message: "删除成功!"
  279. });
  280. this.init();
  281. this.projectVisible = false;
  282. })
  283. })
  284. },
  285. getFont (type) {
  286. if (type == 1) {
  287. return '施';
  288. } else if (type == 2) {
  289. return '监';
  290. } else if (type == 3) {
  291. return '业';
  292. }
  293. return '';
  294. },
  295. getAvatarBg (type) {
  296. if (type == 1) {
  297. return { 'abg1': true };
  298. } else if (type == 2) {
  299. return { 'abg2': true };
  300. } else if (type == 3) {
  301. return { 'abg3': true };
  302. }
  303. return {};
  304. },
  305. getBg (index) {
  306. let num = Math.trunc(index / 4);
  307. if ((num % 2) === 0) {//判定条件余数为0时为偶数
  308. return {
  309. 'bg1': true
  310. }
  311. } else {
  312. return {
  313. 'bg2': true
  314. }
  315. }
  316. },
  317. wbsManage () {//wbs树管理按钮
  318. this.$router.push('/manager/privateWBS/' + 111)
  319. },
  320. }
  321. };
  322. </script>
  323. <style scoped lang="scss">
  324. .project_name {
  325. font-size: 20px;
  326. cursor: pointer;
  327. }
  328. .bg1 {
  329. background-color: rgb(127, 164, 221);
  330. border-color: rgb(187, 187, 187);
  331. box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 6px 0px;
  332. }
  333. .bg2 {
  334. background-color: rgb(239, 240, 229);
  335. border-color: rgb(187, 187, 187);
  336. box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 6px 0px;
  337. }
  338. .abg1 {
  339. background-color: rgb(42, 155, 121);
  340. }
  341. .abg2 {
  342. background-color: rgb(155, 108, 42);
  343. }
  344. .abg3 {
  345. background-color: rgb(42, 53, 155);
  346. }
  347. </style>