14
0

edit.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div class="facilities-dialog-container">
  3. <el-dialog
  4. :title="state.dialog.title"
  5. @close="onCancel"
  6. :close-on-click-modal="false"
  7. v-model="state.dialog.isShowDialog"
  8. width="90%"
  9. >
  10. <h4 class="mb8 mt8">申请信息</h4>
  11. <el-descriptions
  12. border
  13. :column="1"
  14. class="mb20"
  15. direction="vertical"
  16. >
  17. <el-descriptions-item
  18. label-class-name="cell-item"
  19. label="入室申请名称"
  20. >
  21. {{ state.oldForm.userName }}的{{ state.oldForm.platformName }}的入室申请
  22. </el-descriptions-item>
  23. <el-descriptions-item
  24. label-class-name="cell-item"
  25. label="申请平台"
  26. width="50%"
  27. >
  28. {{ state.oldForm.platformName }}
  29. </el-descriptions-item>
  30. <!-- <el-descriptions-item label-class-name="cell-item" label="申请时长">{{ state.oldForm.platformTime }}个月</el-descriptions-item>-->
  31. <el-descriptions-item
  32. label-class-name="cell-item"
  33. label="入室周期"
  34. width="50%"
  35. >
  36. {{ state.oldForm?.startTime ? formatDate(new Date(state.oldForm?.startTime), 'YYYY-mm-dd') : '' }} ~
  37. {{ state.oldForm?.endTime ? formatDate(new Date(state.oldForm?.endTime), 'YYYY-mm-dd') : '' }}
  38. </el-descriptions-item>
  39. <el-descriptions-item
  40. label-class-name="cell-item"
  41. label="预约房间"
  42. width="50%"
  43. >
  44. {{ state.oldForm.resName }}
  45. </el-descriptions-item>
  46. </el-descriptions>
  47. <el-form
  48. ref="expertDialogFormRef"
  49. :model="state.form"
  50. :rules="rules"
  51. size="default"
  52. label-width="140px"
  53. label-position="top"
  54. >
  55. <el-row :gutter="35">
  56. <el-col
  57. :span="24"
  58. class="mb20"
  59. >
  60. <el-form-item
  61. label="开始时间"
  62. prop="startTime"
  63. >
  64. <el-date-picker
  65. type="datetime"
  66. placeholder="请输入"
  67. disabled
  68. class="w100"
  69. v-model="state.form.startTime"
  70. value-format="YYYY-MM-DD HH:mm"
  71. format="YYYY/MM/DD HH:mm"
  72. />
  73. </el-form-item>
  74. </el-col>
  75. <el-col
  76. :span="24"
  77. class="mb20"
  78. >
  79. <el-form-item
  80. label="结束时间"
  81. prop="endTime"
  82. >
  83. <el-date-picker
  84. type="datetime"
  85. placeholder="请输入"
  86. disabled
  87. class="w100"
  88. v-model="state.form.endTime"
  89. value-format="YYYY-MM-DD HH:mm"
  90. format="YYYY/MM/DD HH:mm"
  91. />
  92. </el-form-item>
  93. </el-col>
  94. <el-col
  95. :span="24"
  96. class="mb24"
  97. >
  98. <el-form-item
  99. label="预约时长(分钟)"
  100. prop="duration"
  101. >
  102. <el-input
  103. disabled
  104. placeholder="请输入"
  105. class="w100"
  106. maxlength="11"
  107. v-model="state.form.duration"
  108. />
  109. </el-form-item>
  110. </el-col>
  111. <!-- <el-col :span="12" class="mb24">-->
  112. <!-- <el-form-item label="预约人" prop="userId">-->
  113. <!-- <el-select v-model="state.form.userId" class="w100" filterable placeholder="请选择" disabled @change="changeUser">-->
  114. <!-- <el-option :value="v.id" :label="v.nickName" :key="v.id" v-for="v in userList" />-->
  115. <!-- </el-select>-->
  116. <!-- </el-form-item>-->
  117. <!-- </el-col>-->
  118. <!-- <el-col :span="12" class="mb24">-->
  119. <!-- <el-form-item label="联系电话" prop="userContact">-->
  120. <!-- <el-input placeholder="请输入" class="w100" maxlength="11" v-model="state.form.userContact" />-->
  121. <!-- </el-form-item>-->
  122. <!-- </el-col>-->
  123. <el-col
  124. :span="24"
  125. class="mb20"
  126. >
  127. <el-form-item
  128. label="备注"
  129. prop="remark"
  130. >
  131. <el-input
  132. type="textarea"
  133. v-model="state.form.remark"
  134. placeholder="请输入备注"
  135. ></el-input>
  136. </el-form-item>
  137. </el-col>
  138. </el-row>
  139. </el-form>
  140. <template #footer>
  141. <span class="dialog-footer">
  142. <el-button
  143. type="info"
  144. @click="onCancel"
  145. size="default"
  146. >
  147. 取 消
  148. </el-button>
  149. <el-button
  150. color="#2c78ff"
  151. @click="onSubmit('20')"
  152. size="default"
  153. >
  154. {{ state.dialog.submitTxt }}
  155. </el-button>
  156. </span>
  157. </template>
  158. </el-dialog>
  159. </div>
  160. </template>
  161. <script setup lang="ts" name="systemProDialog">
  162. import { nextTick, reactive, ref } from 'vue'
  163. import to from 'await-to-js'
  164. import { ElMessage } from 'element-plus'
  165. import moment from 'moment/moment'
  166. import { storeToRefs } from 'pinia'
  167. import { useSystemApi } from '/@/api/platform/system'
  168. import { deepClone } from '/@/utils/other'
  169. import { useAppointmentApi } from '/@/api/platform/home/appointment'
  170. import { useUserInfo } from '/@/stores/userInfo'
  171. import { formatDate } from '/@/utils/formatTime'
  172. import { useCellAssignApi } from '/@/api/platform/home/assign'
  173. // 定义子组件向父组件传值/事件
  174. const emit = defineEmits(['refresh'])
  175. // 定义变量内容
  176. const Api = useAppointmentApi()
  177. const assignApi = useCellAssignApi()
  178. const systemApi = useSystemApi()
  179. const expertDialogFormRef = ref()
  180. const stores = useUserInfo()
  181. const { userInfos } = storeToRefs(stores)
  182. const rules = {
  183. startTime: { required: true, message: '不能为空', trigger: 'change' },
  184. endTime: { required: true, message: '不能为空', trigger: 'change' },
  185. userId: { required: true, message: '不能为空', trigger: 'change' },
  186. userContact: { required: true, message: '不能为空', trigger: 'blur' },
  187. }
  188. const state = reactive({
  189. form: {
  190. id: 0,
  191. assignId: 0,
  192. userId: 0,
  193. userName: '',
  194. userDeptId: null,
  195. userDeptName: '',
  196. userContact: '',
  197. startTime: null,
  198. endTime: null,
  199. remark: '',
  200. duration: 0,
  201. },
  202. oldForm: {
  203. id: 0,
  204. appointId: 0,
  205. mainId: 0,
  206. platformId: 0,
  207. platformName: '',
  208. resId: 0,
  209. resLocation: '',
  210. resName: '',
  211. userId: 0,
  212. userName: '',
  213. assignStatus: '',
  214. startTime: '',
  215. endTime: '',
  216. oldStartTime: '',
  217. oldEndTime: '',
  218. isConfirm: '',
  219. location: 0,
  220. outApplyTime: '',
  221. outStatus: 0,
  222. outTime: null,
  223. },
  224. dialog: {
  225. isShowDialog: false,
  226. type: '',
  227. title: '',
  228. submitTxt: '',
  229. },
  230. })
  231. const belongOrgOption = ref<DeptTreeType[]>([])
  232. const userList = ref<any[]>([]) //用户列表
  233. const getDicts = async () => {
  234. await Promise.all([systemApi.getDeptTree(), systemApi.getUserList({ noPage: true })]).then(([dept, user]) => {
  235. belongOrgOption.value = dept?.data || []
  236. userList.value = user?.data.list || []
  237. })
  238. }
  239. // 打开弹窗
  240. const openDialog = async (type: string, row: any) => {
  241. await getDicts()
  242. state.dialog.type = type
  243. state.dialog.title = '入室预约'
  244. if (type == 'add') {
  245. state.form = {
  246. id: 0,
  247. assignId: row?.id,
  248. userId: userInfos.value.id,
  249. userName: userInfos.value.nickName,
  250. userDeptId: userInfos.value.deptId,
  251. userDeptName: userInfos.value.deptName,
  252. userContact: userInfos.value.phone,
  253. startTime: row?.startTime,
  254. endTime: row?.endTime,
  255. remark: '',
  256. }
  257. const [err, res]: ToResponse = await to(assignApi.getDetail({ id: row?.id }))
  258. if (err) return
  259. state.oldForm = res?.data || {}
  260. // 计算startTime和endTime的分钟差
  261. const diff = moment(state.form.endTime).diff(moment(state.form.startTime), 'minutes')
  262. state.form.duration = diff
  263. } else {
  264. const [err, res]: ToResponse = await to(Api.getDetail({ id: row?.id }))
  265. if (err) return
  266. state.form = res?.data || {}
  267. }
  268. state.dialog.submitTxt = '提 交'
  269. state.dialog.isShowDialog = true
  270. // 清空表单,此项需加表单验证才能使用
  271. await nextTick()
  272. }
  273. // 关闭弹窗
  274. const closeDialog = () => {
  275. expertDialogFormRef.value.resetFields()
  276. state.dialog.isShowDialog = false
  277. }
  278. const onCancel = () => {
  279. closeDialog()
  280. }
  281. // 提交
  282. const onSubmit = async (type: string) => {
  283. expertDialogFormRef.value.validate(async (valid: boolean) => {
  284. if (!valid) return
  285. state.form.isTemporary = type
  286. const params = deepClone(state.form)
  287. const post = state.dialog.type == 'add' ? Api.create : Api.updateById
  288. const [err]: ToResponse = await to(post(params))
  289. if (err) return
  290. ElMessage.success('操作成功')
  291. closeDialog()
  292. emit('refresh')
  293. })
  294. }
  295. // 暴露变量
  296. defineExpose({
  297. openDialog,
  298. })
  299. </script>
  300. <style lang="scss" scoped>
  301. h4 {
  302. font-size: 18px;
  303. }
  304. :deep(.disUoloadSty .el-upload--picture-card) {
  305. display: none; /* 上传按钮隐藏 */
  306. }
  307. .avatar-uploader {
  308. :deep(.el-upload) {
  309. width: 100%;
  310. height: 100%;
  311. border: 1px dashed var(--el-border-color);
  312. border-radius: 6px;
  313. cursor: pointer;
  314. position: relative;
  315. overflow: hidden;
  316. transition: var(--el-transition-duration-fast);
  317. &:hover {
  318. border-color: var(--el-color-primary);
  319. }
  320. }
  321. }
  322. .el-icon.avatar-uploader-icon {
  323. font-size: 28px;
  324. color: #8c939d;
  325. width: 178px;
  326. height: 178px;
  327. text-align: center;
  328. }
  329. </style>