info-dialog.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <hc-dialog v-model="isShow" ui="hc-project-info-dialog-box" widths="64rem" is-table title="项目信息" :footer="false" :padding="false" @close="dialogClose">
  3. <el-container class="hc-project-info-dialog">
  4. <el-header>
  5. <div class="left">
  6. <el-button hc-btn color="#626aef" style="color: white" @click="toCheck('measure')">计量管理</el-button>
  7. <el-button hc-btn color="#e233fb" style="color: white" @click="toCheck('lar')">征拆划分</el-button>
  8. <el-button hc-btn color="#ac54ff" style="color: white" @click="toCheck('test')">实验划分</el-button>
  9. <el-button hc-btn type="success" style="color: white" @click="toCheck('wbsTree')">WBS树管理</el-button>
  10. <el-button hc-btn color="#2bbeed" style="color: white" @click="toCheck('logTree')">日志树管理</el-button>
  11. </div>
  12. <div class="right">
  13. <el-button hc-btn type="warning" @click="toCheck('editProject')">编辑项目</el-button>
  14. <el-button hc-btn type="primary" @click="toCheck('addContract')">创建合同段</el-button>
  15. <el-button v-del-com:[delProject] hc-btn type="danger">删除项目</el-button>
  16. </div>
  17. </el-header>
  18. <el-container>
  19. <el-aside width="300px">
  20. <hc-body scrollbar padding="0px">
  21. <hc-list-item title="项目ID:" :content="projectInfo.id" />
  22. <hc-list-item title="项目简称:" :content="projectInfo.projectAlias" />
  23. <hc-list-item title="项目全名:" :content="projectInfo.projectName" />
  24. <hc-list-item title="创建时间:" :content="projectInfo.createTime" />
  25. <hc-list-item title="更新时间:" :content="projectInfo.updateTime" />
  26. </hc-body>
  27. </el-aside>
  28. <el-main>
  29. <hc-body :scrollbar="contractList.length > 0" padding="0px">
  30. <hc-empty v-if="contractList.length <= 0" />
  31. <hc-card-item v-for="item in contractList" v-else :key="item.id" class="hc-contract-list-card">
  32. <div class="contract-type">
  33. <div v-if="item.contractType === 1" class="name bg-1">施工</div>
  34. <div v-if="item.contractType === 2" class="name bg-2">监理</div>
  35. <div v-if="item.contractType === 3" class="name bg-3">业主</div>
  36. </div>
  37. <div class="contract-content">
  38. <div class="name">{{ item.contractName }}</div>
  39. <div class="footer">
  40. <div class="time">{{ item.updateTime }}</div>
  41. <div class="action">
  42. <el-link type="warning" @click="toCheck('editContract', item)">编辑合同段信息</el-link>
  43. <el-link v-if="item.contractType === 1" type="success" @click="toCheck('wbsContract', item)">分配WBS</el-link>
  44. <el-link v-del-com:[delContract]="item" type="danger">删除</el-link>
  45. </div>
  46. </div>
  47. </div>
  48. </hc-card-item>
  49. </hc-body>
  50. </el-main>
  51. </el-container>
  52. </el-container>
  53. </hc-dialog>
  54. </template>
  55. <script setup>
  56. import { ref, watch } from 'vue'
  57. import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
  58. import mainApi from '~api/project/project'
  59. import contractApi from '~api/project/contract'
  60. const props = defineProps({
  61. ids: {
  62. type: [String, Number],
  63. default: '',
  64. },
  65. })
  66. //事件
  67. const emit = defineEmits(['change', 'check', 'close'])
  68. //双向绑定
  69. // eslint-disable-next-line no-undef
  70. const isShow = defineModel('modelValue', {
  71. default: false,
  72. })
  73. //监听数据
  74. const projectId = ref(props.ids)
  75. watch(() => props.ids, (id) => {
  76. projectId.value = id
  77. }, { deep: true })
  78. //监听显示
  79. watch(isShow, (val) => {
  80. if (val) {
  81. getProjectInfo()
  82. } else {
  83. projectInfo.value = {}
  84. projectId.value = ''
  85. emit('close')
  86. }
  87. })
  88. //获取项目信息
  89. const projectInfo = ref({})
  90. const getProjectInfo = async () => {
  91. if (isNullES(projectId.value)) return
  92. const { data } = await mainApi.detail(projectId.value)
  93. projectInfo.value = getObjValue(data)
  94. await getContractList(projectId.value)
  95. }
  96. //获取合同段信息
  97. const contractList = ref([])
  98. const getContractList = async (id) => {
  99. if (isNullES(id)) return
  100. const { data } = await contractApi.getList(id)
  101. contractList.value = getArrValue(data)
  102. }
  103. //关闭弹窗
  104. const dialogClose = () => {
  105. projectInfo.value = {}
  106. isShow.value = false
  107. emit('close')
  108. }
  109. //删除项目
  110. const delProject = async (_, resolve) => {
  111. if (isNullES(projectId.value)) return
  112. const { isRes } = await mainApi.del(projectId.value)
  113. resolve() //关闭弹窗
  114. if (!isRes) return
  115. window.$message.success('删除成功')
  116. dialogClose()
  117. emit('change')
  118. }
  119. //删除合同段
  120. const delContract = async ({ item }, resolve) => {
  121. const { isRes } = await contractApi.del(item.id)
  122. resolve() //关闭弹窗
  123. if (!isRes) return
  124. window.$message.success('删除成功')
  125. getContractList(projectId.value).then()
  126. }
  127. //功能事件回调
  128. const toCheck = (type, item = {}) => {
  129. //measure, lar, test, wbsTree, logTree, editProject, addContract, editContract, wbsContract
  130. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理,编辑项目,创建合同段,编辑合同段信息,分配WBS
  131. const info = deepClone(projectInfo.value)
  132. dialogClose()
  133. emit('check', { type, info, item })
  134. }
  135. </script>
  136. <style lang="scss">
  137. .el-container.hc-project-info-dialog {
  138. position: relative;
  139. height: 100%;
  140. .el-header {
  141. position: relative;
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. --el-header-padding: 0;
  146. --el-header-height: 50px;
  147. border-bottom: 1px solid #f4f4f4;
  148. }
  149. .el-aside, .el-main {
  150. position: relative;
  151. --el-main-padding: 0;
  152. .hc-new-main-body {
  153. top: 10px;
  154. }
  155. }
  156. .el-aside {
  157. border-right: 1px solid #f4f4f4;
  158. .hc-new-main-body {
  159. right: 10px;
  160. }
  161. }
  162. .el-main .hc-new-main-body {
  163. left: 10px;
  164. }
  165. .hc-list-item .title {
  166. width: 70px;
  167. }
  168. .hc-list-item .content {
  169. flex: 1;
  170. }
  171. .hc-contract-list-card {
  172. border-radius: 4px;
  173. margin-bottom: 14px;
  174. cursor: pointer;
  175. padding: 8px 14px;
  176. background: #f3f3f3 !important;
  177. transition: all 0.3s;
  178. .hc-card-item-body {
  179. display: flex;
  180. align-items: center;
  181. }
  182. .contract-type {
  183. position: relative;
  184. margin-right: 14px;
  185. .name {
  186. position: relative;
  187. height: 43px;
  188. width: 43px;
  189. border-radius: 50px;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. color: white;
  194. }
  195. .name.bg-1 {
  196. background-color: #2a9b79;
  197. }
  198. .name.bg-2 {
  199. background-color: #9b6c2a;
  200. }
  201. .name.bg-3 {
  202. background-color: #2a359b;
  203. }
  204. }
  205. .contract-content {
  206. position: relative;
  207. flex: 1;
  208. .name {
  209. color: #101010;
  210. font-weight: bold;
  211. }
  212. .footer {
  213. margin-top: 10px;
  214. position: relative;
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. .time {
  219. color: #747474;
  220. font-size: 14px;
  221. }
  222. .el-link + .el-link{
  223. margin-left: 10px;
  224. }
  225. }
  226. }
  227. &:hover {
  228. box-shadow: 2px 2px var(--el-color-primary-light-7);
  229. }
  230. }
  231. }
  232. .el-overlay-dialog .el-dialog.hc-new-dialog.hc-project-info-dialog-box {
  233. height: 500px;
  234. max-height: 500px;
  235. --el-dialog-margin-top: 15vh;
  236. }
  237. </style>