8
0

info-dialog.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <hc-new-dialog v-model="isShow" 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 hc-btn type="danger" @click="delProject">删除项目</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-no-data 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 type="danger" @click="delContract(item)">删除</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-new-dialog>
  54. </template>
  55. <script setup>
  56. import { delMessage } from 'hc-vue3-ui'
  57. import { ref, watch } from 'vue'
  58. import { deepClone, getArrValue, getObjValue, isNullES } from 'js-fast-way'
  59. import mainApi from '~api/project/project'
  60. import contractApi from '~api/project/contract'
  61. const props = defineProps({
  62. ids: {
  63. type: [String, Number],
  64. default: () => '',
  65. },
  66. })
  67. //事件
  68. const emit = defineEmits(['change', 'check'])
  69. //双向绑定
  70. // eslint-disable-next-line no-undef
  71. const isShow = defineModel('modelValue', {
  72. default: false,
  73. })
  74. //监听数据
  75. const projectId = ref(props.ids)
  76. watch(() => props.ids, (id) => {
  77. projectId.value = id
  78. }, { immediate: true, deep: true })
  79. //监听显示
  80. watch(isShow, (val) => {
  81. if (val) {
  82. getProjectInfo()
  83. } else {
  84. projectInfo.value = {}
  85. projectId.value = ''
  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. }
  109. //删除项目
  110. const delProject = () => {
  111. if (isNullES(projectId.value)) return
  112. delMessage(async () => {
  113. const { error, code, msg } = await mainApi.del(projectId.value)
  114. if (!error && code === 200) {
  115. window.$message.success('删除成功')
  116. dialogClose()
  117. emit('change')
  118. } else {
  119. window.$message.error(msg ?? '删除失败')
  120. }
  121. })
  122. }
  123. //删除合同段
  124. const delContract = (item) => {
  125. delMessage(async () => {
  126. const { error, code, msg } = await contractApi.del(item.id)
  127. if (!error && code === 200) {
  128. window.$message.success('删除成功')
  129. getContractList(projectId.value).then()
  130. } else {
  131. window.$message.error(msg ?? '删除失败')
  132. }
  133. })
  134. }
  135. //功能事件回调
  136. const toCheck = (type, item = {}) => {
  137. //measure, lar, test, wbsTree, logTree, editProject, addContract, editContract, wbsContract
  138. //计量管理,征拆划分,实验划分,WBS树管理,日志树管理,编辑项目,创建合同段,编辑合同段信息,分配WBS
  139. const info = deepClone(projectInfo.value)
  140. dialogClose()
  141. emit('check', { type, info, item })
  142. }
  143. </script>
  144. <style lang="scss">
  145. .el-container.hc-project-info-dialog {
  146. position: relative;
  147. height: 100%;
  148. .el-header {
  149. position: relative;
  150. display: flex;
  151. align-items: center;
  152. justify-content: space-between;
  153. --el-header-padding: 0;
  154. --el-header-height: 50px;
  155. border-bottom: 1px solid #f4f4f4;
  156. }
  157. .el-aside, .el-main {
  158. position: relative;
  159. --el-main-padding: 0;
  160. .hc-new-main-body {
  161. top: 10px;
  162. }
  163. }
  164. .el-aside {
  165. border-right: 1px solid #f4f4f4;
  166. .hc-new-main-body {
  167. right: 10px;
  168. }
  169. }
  170. .el-main .hc-new-main-body {
  171. left: 10px;
  172. }
  173. .hc-list-item .title {
  174. width: 70px;
  175. }
  176. .hc-list-item .content {
  177. flex: 1;
  178. }
  179. .hc-contract-list-card {
  180. border-radius: 4px;
  181. margin-right: 14px;
  182. margin-bottom: 14px;
  183. cursor: pointer;
  184. padding: 8px 14px;
  185. background: #f3f3f3 !important;
  186. transition: all 0.3s;
  187. .hc-card-item-body {
  188. display: flex;
  189. align-items: center;
  190. }
  191. .contract-type {
  192. position: relative;
  193. margin-right: 14px;
  194. .name {
  195. position: relative;
  196. height: 43px;
  197. width: 43px;
  198. border-radius: 50px;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. color: white;
  203. }
  204. .name.bg-1 {
  205. background-color: #2a9b79;
  206. }
  207. .name.bg-2 {
  208. background-color: #9b6c2a;
  209. }
  210. .name.bg-3 {
  211. background-color: #2a359b;
  212. }
  213. }
  214. .contract-content {
  215. position: relative;
  216. flex: 1;
  217. .name {
  218. color: #101010;
  219. font-weight: bold;
  220. }
  221. .footer {
  222. margin-top: 10px;
  223. position: relative;
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. .time {
  228. color: #747474;
  229. font-size: 14px;
  230. }
  231. .el-link + .el-link{
  232. margin-left: 10px;
  233. }
  234. }
  235. }
  236. &:hover {
  237. box-shadow: 2px 2px var(--el-color-primary-light-7);
  238. }
  239. }
  240. }
  241. </style>