移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

otherOpenEdit.vue 7.9 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="home_wrapper">
  3. <div class="header_main">
  4. {{titlePreifx}}{{title}}
  5. <div class="return_btn" @click="back()"></div>
  6. </div>
  7. <van-form ref="formData" :show-error-message="false" @submit="submit">
  8. <div class="list_main">
  9. <field-select
  10. v-if="showTypeSelector"
  11. v-model="form.otherType"
  12. label="公开类型"
  13. value-key="dictLabel"
  14. data-key="dictValue"
  15. placeholder="请选择公开类型"
  16. :rules="rules.otherType"
  17. required
  18. size="large"
  19. :columns="otherTypeOptions"/>
  20. <van-field name="otherName" v-model="form.otherName" label="公开名称" input-align="right" required :rules="rules.otherName" placeholder="请输入公开名称" size="large" :maxlength="150"/>
  21. <field-date-picker
  22. name="openAt"
  23. class="field_no-label"
  24. v-model="form.openAt"
  25. placeholder="请选择公开时间"
  26. formatter="yyyy-MM-dd"
  27. input-align="right"
  28. type="date"
  29. label="公开时间"
  30. :required="true"
  31. :rules="rules.openAt"
  32. size="large"
  33. />
  34. <van-field name="openContent" label="公开内容" size="large" :border="false"/>
  35. <vue-html5-editor :content="content" :height="300" @change="updateData" style="margin-top: 0.2rem;"></vue-html5-editor>
  36. <van-field
  37. name="openPic"
  38. label="公开图片"
  39. input-align="right"
  40. :border="false"
  41. >
  42. </van-field>
  43. <CommonUpload name="openPic" v-model="form.openPic" accept="image/*" multiple/>
  44. <van-field
  45. name="openFile"
  46. label="公开文件"
  47. input-align="right"
  48. :border="false"
  49. >
  50. </van-field>
  51. <CommonUpload name="openFile" v-model="form.openFile" accept="*" multiple/>
  52. <van-field name="remark" v-model="form.remark" label="备注" input-align="left" size="large" :maxlength="255" placeholder="请输入备注"/>
  53. </div>
  54. <div style="margin: 16px auto;width: 50%;">
  55. <van-button round block type="primary" native-type="submit">
  56. 保存
  57. </van-button>
  58. </div>
  59. </van-form>
  60. </div>
  61. </template>
  62. <script>
  63. import CommonUpload from "@/components/form/CommonUpload.vue";
  64. import FieldDatePicker from "@/components/form/FieldDatePicker.vue";
  65. import {Toast} from "vant";
  66. import {addOther, getOther, updateOther} from "@/api/sunVillage_info/otherOpen";
  67. import FieldSelect from "@/components/form/FieldSelect.vue";
  68. export default {
  69. name: "otherOpenEdit",
  70. components: {FieldSelect, FieldDatePicker, CommonUpload},
  71. data() {
  72. return {
  73. form: {
  74. id: null,
  75. bookId: null,
  76. deptId: null,
  77. deptName: null,
  78. otherName: null,
  79. otherType: null,
  80. openYear: null,
  81. openAt: null,
  82. openContent: null,
  83. openFile: null,
  84. openPic: null,
  85. remark: null,
  86. createBy: null,
  87. createTime: null,
  88. updateBy: null,
  89. updateTime: null,
  90. },
  91. rules: {
  92. openAt: [{message: '请选择公开时间', required: true}],
  93. otherName: [{message: '请输入公开名称', required: true}],
  94. otherType: [{message: '请选择公开类型', required: true}],
  95. },
  96. id: null,
  97. intent: null,
  98. content: '',
  99. otherTypeOptions: [],
  100. otherType: null,
  101. title: '综合公开',
  102. };
  103. },
  104. created() {
  105. this.id = this.$route.query.id;
  106. this.intent = this.$route.query.intent;
  107. this.otherType = this.$route.query.otherType;
  108. if(this.isEdit)
  109. this.getDetail();
  110. else
  111. {
  112. this.form.otherType = this.$route.query.otherType;
  113. this.getDicts('other_gk_type').then((resp) => {
  114. this.otherTypeOptions = resp.data;
  115. const dict = resp.data.find((x) => x.dictValue == this.form.otherType);
  116. if(dict)
  117. this.title = dict.dictLabel;
  118. });
  119. }
  120. },
  121. methods: {
  122. getDetail() {
  123. if(!this.id)
  124. {
  125. this.back();
  126. return;
  127. }
  128. getOther(this.id).then((resp) => {
  129. this.form = resp.data;
  130. this.content = this.form.openContent || '';
  131. this.getDicts('other_gk_type').then((resp) => {
  132. const dict = resp.data.find((x) => x.dictValue == this.form.otherType);
  133. if(dict)
  134. this.title = dict.dictLabel;
  135. });
  136. });
  137. },
  138. back(ti) {
  139. if(ti > 0)
  140. setTimeout(() => this.$router.back(), ti);
  141. else
  142. this.$router.back();
  143. },
  144. updateData(t) {
  145. this.form.openContent = t;
  146. },
  147. submit() {
  148. const loading = Toast.loading({
  149. message: '保存中...',
  150. duration: 0,
  151. });
  152. if(this.form.id)
  153. {
  154. updateOther(this.form).then((resp) => {
  155. this.$notify({ type: 'success', message: '保存成功' });
  156. this.back(1500);
  157. }).finally(() => {
  158. loading.clear();
  159. });
  160. }
  161. else
  162. {
  163. addOther(this.form).then((resp) => {
  164. this.$notify({ type: 'success', message: '新增成功' });
  165. this.back(1500);
  166. }).finally(() => {
  167. loading.clear();
  168. });
  169. }
  170. },
  171. },
  172. computed: {
  173. isAdd() {
  174. return this.intent === 'add';
  175. },
  176. isEdit() {
  177. return this.intent === 'edit';
  178. },
  179. titlePreifx() {
  180. return this.intent === 'edit' ? '编辑' : '新增';
  181. },
  182. showTypeSelector() {
  183. return this.isAdd && !this.otherType;
  184. },
  185. },
  186. }
  187. </script>
  188. <style scoped lang="scss">
  189. /deep/ .van-button--primary{
  190. background: url("../../../assets/images/sunVillage_info/btn_bg.png") no-repeat;
  191. background-size: 100% 100%;
  192. border: none;
  193. }
  194. .home_wrapper{
  195. background: #e9e9e9;
  196. min-height: 100vh;
  197. width: 100vw;
  198. .header_main {
  199. height: 116px;
  200. background: url('../../../assets/images/sunVillage_info/list_head.png') no-repeat;
  201. background-size: 100% 100%;
  202. position: fixed;
  203. top: 0;
  204. left: 0;
  205. width: 100%;
  206. font-size: 36px;
  207. line-height: 116px;
  208. text-align: center;
  209. color: #fff;
  210. position: relative;
  211. .return_btn {
  212. width: 24px;
  213. height: 43.2px;
  214. background: url('../../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
  215. background-size: 20px 36px;
  216. position: absolute;
  217. left: 38px;
  218. top: 36px;
  219. }
  220. .add_btn {
  221. width: 56.4px;
  222. height: 40.8px;
  223. background: url('../../../assets/images/sunVillage_info/list_icon_9.png') center center no-repeat;
  224. background-size: 47px 34px;
  225. position: absolute;
  226. right: 38px;
  227. top: 36px;
  228. }
  229. }
  230. .list_main{
  231. padding:25px;
  232. background: #ffffff;
  233. width: 94%;
  234. margin: 25px auto 0;
  235. border-radius: 15PX;
  236. box-shadow: 4px 6px 5px rgba(63, 68, 75, 0.1);
  237. }
  238. .titBox{
  239. display: flex;
  240. align-items: center;
  241. }
  242. .tit{
  243. font-size: 36px;
  244. font-weight: bold;
  245. }
  246. /deep/ .van-cell{
  247. padding-left: 0!important;
  248. padding-right: 0!important;
  249. padding-bottom: 0!important;
  250. }
  251. /deep/ .van-field__label{
  252. padding-left: 10PX;
  253. width: 8.2em;
  254. }
  255. /deep/ .van-cell--required::before{
  256. left: 0;
  257. }
  258. }
  259. </style>