8
0

info-dialog.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. projectId.value = ''
  106. projectInfo.value = {}
  107. isShow.value = false
  108. emit('close')
  109. }
  110. //删除项目
  111. const delProject = async (_, resolve) => {
  112. if (isNullES(projectId.value)) return
  113. const { isRes } = await mainApi.del(projectId.value)
  114. resolve() //关闭弹窗
  115. if (!isRes) return
  116. window.$message.success('删除成功')
  117. dialogClose()
  118. emit('change')
  119. }
  120. //删除合同段
  121. const delContract = async ({ item }, resolve) => {
  122. const { isRes } = await contractApi.del(item.id)
  123. resolve() //关闭弹窗
  124. if (!isRes) return
  125. window.$message.success('删除成功')
  126. getContractList(projectId.value).then()
  127. }
  128. //功能事件回调
  129. const toCheck = (type, item = {}) => {
  130. //measure, lar, test, wbsTree, logTree, editProject, addContract, editContract, wbsContract
  131. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理,编辑项目,创建合同段,编辑合同段信息,分配WBS
  132. const info = deepClone(projectInfo.value)
  133. dialogClose()
  134. emit('check', { type, info, item })
  135. }
  136. </script>
  137. <style lang="scss">
  138. .el-container.hc-project-info-dialog {
  139. position: relative;
  140. height: 100%;
  141. .el-header {
  142. position: relative;
  143. display: flex;
  144. align-items: center;
  145. justify-content: space-between;
  146. --el-header-padding: 0;
  147. --el-header-height: 50px;
  148. border-bottom: 1px solid #f4f4f4;
  149. }
  150. .el-aside, .el-main {
  151. position: relative;
  152. --el-main-padding: 0;
  153. .hc-new-main-body {
  154. top: 10px;
  155. }
  156. }
  157. .el-aside {
  158. border-right: 1px solid #f4f4f4;
  159. .hc-new-main-body {
  160. right: 10px;
  161. }
  162. }
  163. .el-main .hc-new-main-body {
  164. left: 10px;
  165. }
  166. .hc-list-item .title {
  167. width: 70px;
  168. }
  169. .hc-list-item .content {
  170. flex: 1;
  171. }
  172. .hc-contract-list-card {
  173. border-radius: 4px;
  174. margin-bottom: 14px;
  175. cursor: pointer;
  176. padding: 8px 14px;
  177. background: #f3f3f3 !important;
  178. transition: all 0.3s;
  179. .hc-card-item-body {
  180. display: flex;
  181. align-items: center;
  182. }
  183. .contract-type {
  184. position: relative;
  185. margin-right: 14px;
  186. .name {
  187. position: relative;
  188. height: 43px;
  189. width: 43px;
  190. border-radius: 50px;
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. color: white;
  195. }
  196. .name.bg-1 {
  197. background-color: #2a9b79;
  198. }
  199. .name.bg-2 {
  200. background-color: #9b6c2a;
  201. }
  202. .name.bg-3 {
  203. background-color: #2a359b;
  204. }
  205. }
  206. .contract-content {
  207. position: relative;
  208. flex: 1;
  209. .name {
  210. color: #101010;
  211. font-weight: bold;
  212. }
  213. .footer {
  214. margin-top: 10px;
  215. position: relative;
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-between;
  219. .time {
  220. color: #747474;
  221. font-size: 14px;
  222. }
  223. .el-link + .el-link{
  224. margin-left: 10px;
  225. }
  226. }
  227. }
  228. &:hover {
  229. box-shadow: 2px 2px var(--el-color-primary-light-7);
  230. }
  231. }
  232. }
  233. .el-overlay-dialog .el-dialog.hc-new-dialog.hc-project-info-dialog-box {
  234. height: 500px;
  235. max-height: 500px;
  236. --el-dialog-margin-top: 15vh;
  237. }
  238. </style>