dialog.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <style scoped lang="scss">
  2. </style>
  3. <template>
  4. <div class="system-dialog-container">
  5. <el-dialog
  6. :title="state.dialog.title"
  7. v-model="state.dialog.isShowDialog"
  8. width="820px"
  9. draggable
  10. destroy-on-close
  11. :close-on-click-modal="false"
  12. align-center>
  13. <el-form
  14. inline
  15. :model="state.ruleForm"
  16. :rules="rules"
  17. label-position="top"
  18. ref="formRef"
  19. size="default"
  20. label-width="100px"
  21. class="mt5">
  22. <el-form-item label="地址" prop="address">
  23. <el-input
  24. v-model="state.ruleForm.address"
  25. placeholder="地址"
  26. clearable
  27. class="wd350">
  28. </el-input>
  29. </el-form-item>
  30. <el-form-item label="营业时间描述" prop="businessHours">
  31. <el-input
  32. v-model="state.ruleForm.businessHours"
  33. placeholder="营业时间描述"
  34. clearable
  35. class="wd350">
  36. </el-input>
  37. </el-form-item>
  38. <el-form-item label="公司id" prop="companyId">
  39. <el-input
  40. v-model="state.ruleForm.companyId"
  41. placeholder="公司id"
  42. clearable
  43. class="wd350">
  44. </el-input>
  45. </el-form-item>
  46. <el-form-item label="站点坐标" prop="location">
  47. <el-input
  48. v-model="state.ruleForm.location"
  49. placeholder="站点坐标"
  50. clearable
  51. class="wd350">
  52. </el-input>
  53. </el-form-item>
  54. <el-form-item label="停车费描述:eg:洗车费用满10元减免1小时停车费" prop="parkingFee">
  55. <el-input
  56. v-model="state.ruleForm.parkingFee"
  57. placeholder="停车费描述:eg:洗车费用满10元减免1小时停车费"
  58. clearable
  59. class="wd350">
  60. </el-input>
  61. </el-form-item>
  62. <el-form-item label="工位数量" prop="parkingNum">
  63. <el-input
  64. v-model="state.ruleForm.parkingNum"
  65. placeholder="工位数量"
  66. clearable
  67. class="wd350">
  68. </el-input>
  69. </el-form-item>
  70. <el-form-item label="站点照片" prop="pictures">
  71. <el-input
  72. v-model="state.ruleForm.pictures"
  73. placeholder="站点照片"
  74. clearable
  75. class="wd350">
  76. </el-input>
  77. </el-form-item>
  78. <el-form-item label="备注" prop="remark">
  79. <el-input
  80. v-model="state.ruleForm.remark"
  81. placeholder="备注"
  82. clearable
  83. class="wd350">
  84. </el-input>
  85. </el-form-item>
  86. <el-form-item label="服务电话" prop="serviceTel">
  87. <el-input
  88. v-model="state.ruleForm.serviceTel"
  89. placeholder="服务电话"
  90. clearable
  91. class="wd350">
  92. </el-input>
  93. </el-form-item>
  94. <el-form-item label="站点引导" prop="siteGuide">
  95. <el-input
  96. v-model="state.ruleForm.siteGuide"
  97. placeholder="站点引导"
  98. clearable
  99. class="wd350">
  100. </el-input>
  101. </el-form-item>
  102. <el-form-item label="站点id" prop="stationId">
  103. <el-input
  104. v-model="state.ruleForm.stationId"
  105. placeholder="站点id"
  106. clearable
  107. class="wd350">
  108. </el-input>
  109. </el-form-item>
  110. <el-form-item label="站点名称" prop="stationName">
  111. <el-input
  112. v-model="state.ruleForm.stationName"
  113. placeholder="站点名称"
  114. clearable
  115. class="wd350">
  116. </el-input>
  117. </el-form-item>
  118. <el-form-item label="站点状态:Unknown:未知,Normal:正常运营,Offline:关闭下线,Repair:维护中" prop="stationStatus">
  119. <el-input
  120. v-model="state.ruleForm.stationStatus"
  121. placeholder="站点状态:Unknown:未知,Normal:正常运营,Offline:关闭下线,Repair:维护中"
  122. clearable
  123. class="wd350">
  124. </el-input>
  125. </el-form-item>
  126. <el-form-item label="站点电话" prop="stationTel">
  127. <el-input
  128. v-model="state.ruleForm.stationTel"
  129. placeholder="站点电话"
  130. clearable
  131. class="wd350">
  132. </el-input>
  133. </el-form-item>
  134. <el-form-item label="站点类型:Public:公共站 2:Private:内部站(不对外开放)" prop="stationType">
  135. <el-input
  136. v-model="state.ruleForm.stationType"
  137. placeholder="站点类型:Public:公共站 2:Private:内部站(不对外开放)"
  138. clearable
  139. class="wd350">
  140. </el-input>
  141. </el-form-item>
  142. </el-form>
  143. <template #footer>
  144. <span class="dialog-footer">
  145. <el-button @click="onCancel" size="default">取 消</el-button>
  146. <el-button :loading="state.btnLoading" type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
  147. </span>
  148. </template>
  149. </el-dialog>
  150. </div>
  151. </template>
  152. <script setup lang="ts" name="WashStationDialog">
  153. import {defineAsyncComponent, reactive, onMounted, ref} from 'vue';
  154. import {Msg} from "/@/utils/message";
  155. import {$body, $get} from "/@/utils/request";
  156. import u from '/@/utils/u'
  157. // 引入组件
  158. // 定义子组件向父组件传值/事件
  159. const emit = defineEmits(['refresh']);
  160. const formRef = ref();
  161. //定义初始变量,重置使用
  162. const initState = () => ({
  163. ruleForm: {
  164. id: 0
  165. },
  166. btnLoading: false,
  167. dialog: {
  168. isShowDialog: false,
  169. type: '',
  170. title: '',
  171. submitTxt: '',
  172. },
  173. rules: {},
  174. })
  175. // 定义变量内容
  176. const state = reactive(initState());
  177. // 打开弹窗
  178. const open = (action: string = 'add', row: any) => {
  179. state.dialog.title = u.dialog.actions[action].title + "『洗车站点表』"
  180. state.dialog.submitTxt = u.dialog.actions[action].btn + "『洗车站点表』"
  181. state.dialog.isShowDialog = true;
  182. if (action !== 'add') {
  183. loadData(row.id);
  184. } else {
  185. state.ruleForm = Object.assign(state.ruleForm, row);
  186. }
  187. };
  188. // 关闭弹窗
  189. const onClose = () => {
  190. state.dialog.isShowDialog = false;
  191. Object.assign(state, initState())
  192. };
  193. // 取消
  194. const onCancel = () => {
  195. onClose();
  196. };
  197. // 提交
  198. const onSubmit = () => {
  199. formRef.value.validate((v: boolean) => {
  200. if (v) {
  201. state.btnLoading = true;
  202. const url = state.ruleForm.id > 0 ? "washStation/modify" : "washStation/add"
  203. $body(url, state.ruleForm).then(() => {
  204. state.btnLoading = false;
  205. Msg.message('操作成功');
  206. console.log('submit!')
  207. onClose();
  208. emit('refresh');
  209. })
  210. } else {
  211. state.btnLoading = false;
  212. Msg.message('请先完整填写表单', 'error');
  213. }
  214. })
  215. };
  216. const handleFormChange = (formData: any) => {
  217. console.log(formData)
  218. }
  219. // 初始化数据
  220. const loadData = (id: number) => {
  221. $get(`washStation/detail/${id}`).then((res: any) => {
  222. state.ruleForm = res;
  223. })
  224. }
  225. // 暴露变量
  226. defineExpose({
  227. open
  228. });
  229. </script>