emergencyPlanDialog.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <u-popup
  3. :show="visible"
  4. mode="bottom"
  5. :round="10"
  6. :closeOnClickOverlay="false"
  7. @close="cancel"
  8. class="emergency-plan-popup"
  9. >
  10. <view class="popup-content">
  11. <!-- 头部 -->
  12. <view class="popup-header">
  13. <text class="popup-title">{{ dialogTitle }}</text>
  14. <view class="close-btn" @click="cancel">×</view>
  15. </view>
  16. <scroll-view class="popup-body" scroll-y>
  17. <view class="page">
  18. <view class="card-a">
  19. <view class="card-section">
  20. <!-- ===== 表单 ===== -->
  21. <u--form
  22. labelPosition="left"
  23. labelWidth="160rpx"
  24. :model="form"
  25. :rules="rules"
  26. ref="formRef"
  27. >
  28. <!-- 预案文件 -->
  29. <u-form-item
  30. label="预案文件"
  31. prop="fileUrl"
  32. borderBottom
  33. required
  34. >
  35. <fileMain
  36. v-model="form.fileUrl"
  37. :type="isView ? 'view' : ''"
  38. />
  39. </u-form-item>
  40. <!-- 预案名称 -->
  41. <u-form-item label="预案名称" prop="name" borderBottom required>
  42. <u--input
  43. v-model="form.name"
  44. placeholder="请输入预案名称"
  45. :disabled="isView"
  46. border="none"
  47. inputAlign="right"
  48. />
  49. </u-form-item>
  50. <!-- 所属部门 -->
  51. <u-form-item
  52. label="所属部门"
  53. prop="departmentId"
  54. borderBottom
  55. required
  56. >
  57. <view class="picker-value">
  58. {{ form.departmentName || "请选择部门" }}
  59. </view>
  60. <u-icon slot="right" name="arrow-right" />
  61. </u-form-item>
  62. <!-- 预案类型 -->
  63. <u-form-item label="预案类型" prop="type" borderBottom required>
  64. <view class="picker-value">
  65. {{ getDictValue("应急预案类型", form.type) || "请选择" }}
  66. </view>
  67. <u-icon slot="right" name="arrow-right" />
  68. </u-form-item>
  69. <!-- 发布时间 -->
  70. <u-form-item label="发布时间" prop="publishTime" borderBottom>
  71. <view class="picker-value">
  72. {{ form.publishTime || "请选择" }}
  73. </view>
  74. <u-icon slot="right" name="arrow-right" />
  75. </u-form-item>
  76. <!-- 标签 -->
  77. <u-form-item label="标签" prop="tags" borderBottom>
  78. <u--input
  79. v-model="form.tags"
  80. placeholder="请输入标签"
  81. :disabled="isView"
  82. border="none"
  83. inputAlign="right"
  84. />
  85. </u-form-item>
  86. </u--form>
  87. </view>
  88. <!-- ===== 编写组成员 ===== -->
  89. <view class="card-section">
  90. <view class="section-title"> 👥 组成员 </view>
  91. <view
  92. v-for="(member, idx) in form.planMemberList"
  93. :key="idx"
  94. class="member-item"
  95. >
  96. <view class="member-info">
  97. <text class="member-name">{{ member.memberUserName }}</text>
  98. <text class="member-dept">{{
  99. member.memberUserDeptName
  100. }}</text>
  101. <text class="member-phone">{{ member.phone }}</text>
  102. </view>
  103. </view>
  104. <view v-if="form.planMemberList.length === 0" class="empty-tip">
  105. 暂无组成员
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </scroll-view>
  111. <!-- 底部按钮 -->
  112. <view class="popup-footer">
  113. <u-button type="default" @click="cancel">取消</u-button>
  114. </view>
  115. </view>
  116. <u-toast ref="uToast" />
  117. </u-popup>
  118. </template>
  119. <script>
  120. import fileMain from "@/pages/doc/index.vue";
  121. import dictMixins from "@/mixins/dictMixins";
  122. import { getEmergencyplanById } from "@/api/emergencyDrill/workOrder.js";
  123. const defForm = {
  124. id: "",
  125. name: "",
  126. departmentId: "",
  127. departmentName: "",
  128. type: "",
  129. publishTime: "",
  130. tags: "",
  131. fileUrl: [],
  132. planMemberList: [],
  133. };
  134. export default {
  135. components: { fileMain, },
  136. mixins: [dictMixins],
  137. data() {
  138. return {
  139. visible: false,
  140. loading: false,
  141. dialogType: "add", // add, edit, view
  142. form: JSON.parse(JSON.stringify(defForm)),
  143. rules: {},
  144. };
  145. },
  146. computed: {
  147. dialogTitle() {
  148. const map = {
  149. add: "新增应急预案",
  150. edit: "编辑应急预案",
  151. view: "查看应急预案",
  152. };
  153. return map[this.dialogType] || "应急预案";
  154. },
  155. isView() {
  156. return this.dialogType === "view";
  157. },
  158. },
  159. mounted() {},
  160. methods: {
  161. // 打开弹窗
  162. async open(row, type = "add") {
  163. this.visible = true;
  164. this.dialogType = type;
  165. this.loading = false;
  166. if (row && row.id) {
  167. try {
  168. const data = await getEmergencyplanById(row.id);
  169. this.form = { ...data };
  170. } catch (e) {
  171. console.error(e);
  172. }
  173. } else {
  174. this.form = JSON.parse(JSON.stringify(defForm));
  175. }
  176. this.$nextTick(() => {
  177. if (this.$refs.formRef) {
  178. this.$refs.formRef.setRules(this.rules);
  179. }
  180. });
  181. },
  182. cancel() {
  183. this.visible = false;
  184. this.form = JSON.parse(JSON.stringify(defForm));
  185. },
  186. },
  187. };
  188. </script>
  189. <style lang="scss" scoped>
  190. .emergency-plan-popup {
  191. /deep/ .u-popup__content {
  192. border-radius: 32rpx 32rpx 0 0;
  193. overflow: hidden;
  194. }
  195. .popup-content {
  196. height: 80vh;
  197. display: flex;
  198. flex-direction: column;
  199. background: #eff2f7;
  200. }
  201. .popup-header {
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. padding: 30rpx 32rpx;
  206. background: #fff;
  207. border-bottom: 2rpx solid #eef2f6;
  208. flex-shrink: 0;
  209. .popup-title {
  210. font-size: 36rpx;
  211. font-weight: bold;
  212. color: #1f2b3c;
  213. }
  214. .close-btn {
  215. width: 60rpx;
  216. height: 60rpx;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. font-size: 52rpx;
  221. color: #8e9aae;
  222. line-height: 1;
  223. }
  224. }
  225. .popup-body {
  226. flex: 1;
  227. overflow-y: auto;
  228. padding: 24rpx;
  229. }
  230. .page {
  231. font-family:
  232. system-ui,
  233. -apple-system,
  234. "Segoe UI",
  235. Roboto,
  236. sans-serif;
  237. }
  238. .card-a {
  239. background: #ffffff;
  240. border-radius: 48rpx;
  241. box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.05);
  242. overflow: hidden;
  243. }
  244. .card-section {
  245. padding: 30rpx 32rpx;
  246. &:not(:last-child) {
  247. border-bottom: 2rpx solid #f0f2f5;
  248. }
  249. }
  250. .section-title {
  251. font-size: 30rpx;
  252. font-weight: 700;
  253. color: #1f2a44;
  254. margin-bottom: 24rpx;
  255. padding-left: 16rpx;
  256. border-left: 6rpx solid #4caf50;
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. .add-btn {
  261. font-size: 26rpx;
  262. color: #2979ff;
  263. font-weight: normal;
  264. padding: 4rpx 16rpx;
  265. background: #e8f0fe;
  266. border-radius: 30rpx;
  267. }
  268. }
  269. /deep/ .u-form-item {
  270. padding: 12rpx 0;
  271. .u-form-item__body__left__label {
  272. font-size: 26rpx !important;
  273. color: #6c7a91 !important;
  274. }
  275. .u-input__content__field-wrapper__field {
  276. font-size: 26rpx !important;
  277. text-align: right;
  278. }
  279. }
  280. .picker-value {
  281. font-size: 26rpx;
  282. color: #1e2a3a;
  283. text-align: right;
  284. flex: 1;
  285. min-height: 44rpx;
  286. padding: 4rpx 0;
  287. }
  288. // ===== 成员列表 =====
  289. .member-item {
  290. display: flex;
  291. align-items: center;
  292. justify-content: space-between;
  293. padding: 16rpx 20rpx;
  294. background: #f5f7fb;
  295. border-radius: 16rpx;
  296. margin-bottom: 12rpx;
  297. .member-info {
  298. display: flex;
  299. align-items: center;
  300. gap: 20rpx;
  301. flex: 1;
  302. flex-wrap: wrap;
  303. .member-name {
  304. font-size: 28rpx;
  305. font-weight: 600;
  306. color: #1f2b3c;
  307. }
  308. .member-dept {
  309. font-size: 24rpx;
  310. color: #8e9aae;
  311. }
  312. .member-phone {
  313. font-size: 24rpx;
  314. color: #8e9aae;
  315. }
  316. }
  317. .member-delete {
  318. width: 48rpx;
  319. height: 48rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. color: #f56c6c;
  324. font-size: 28rpx;
  325. }
  326. }
  327. .empty-tip {
  328. text-align: center;
  329. font-size: 26rpx;
  330. color: #aaa;
  331. padding: 30rpx 0;
  332. }
  333. // ===== 底部按钮 =====
  334. .popup-footer {
  335. display: flex;
  336. padding: 16rpx 24rpx;
  337. background: #fff;
  338. border-top: 2rpx solid #eef2f6;
  339. gap: 16rpx;
  340. flex-shrink: 0;
  341. /deep/ .u-button {
  342. flex: 1;
  343. border-radius: 48rpx;
  344. height: 72rpx;
  345. }
  346. }
  347. }
  348. </style>