notificationEdit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="edit">
  3. <div class="i-layout-page-header">
  4. <router-link :to="{ path: '/admin/setting/notification/index' }"
  5. ><Button icon="ios-arrow-back" size="small" type="text"
  6. >返回</Button
  7. ></router-link
  8. >
  9. <Divider type="vertical" />
  10. <span class="ivu-page-header-title">{{ $route.meta.title }}</span>
  11. </div>
  12. <div class="tabs">
  13. <Row :gutter="32">
  14. <Col span="32" class="demo-tabs-style1" style="padding: 16px">
  15. <Tabs @on-click="changeTabs">
  16. <TabPane
  17. v-for="(item, index) in tabsList"
  18. :key="index"
  19. :name="item.slot"
  20. :label="item.title"
  21. >
  22. <Form
  23. class="form-sty"
  24. ref="formData"
  25. :model="formData"
  26. :rules="ruleValidate"
  27. :label-width="80"
  28. >
  29. <div v-if="item.slot === 'is_system' && !loading">
  30. <FormItem label="通知标题">
  31. <Input
  32. v-model="formData.system_title"
  33. placeholder="请输入通知标题"
  34. style="width: 500px"
  35. ></Input>
  36. </FormItem>
  37. <FormItem label="通知内容">
  38. <div class="content">
  39. <Input
  40. v-model="formData.system_text"
  41. type="textarea"
  42. :autosize="{ minRows: 5, maxRows: 8 }"
  43. placeholder="请输入通知内容"
  44. style="width: 500px"
  45. ></Input>
  46. <div class="trip">
  47. <div>
  48. 请输入模板消息详细内容对应的变量。关键字个数需与已添加的模板一致。
  49. 可以使用如下变量:
  50. </div>
  51. <div
  52. v-for="(item, index) in formData.variable.split(',')"
  53. :key="index"
  54. >
  55. {{ item }}
  56. </div>
  57. </div>
  58. </div>
  59. </FormItem>
  60. <FormItem label="状态" prop="is_system">
  61. <RadioGroup v-model="formData.is_system">
  62. <Radio :label="1">开启</Radio>
  63. <Radio :label="2">关闭</Radio>
  64. </RadioGroup>
  65. </FormItem>
  66. </div>
  67. <div v-if="item.slot === 'is_sms' && !loading">
  68. <FormItem label="短信模版ID">
  69. <Input
  70. v-model="formData.sms_id"
  71. placeholder="短信模版ID"
  72. style="width: 500px"
  73. ></Input>
  74. </FormItem>
  75. <FormItem label="通知内容">
  76. <div class="content">
  77. <Input
  78. v-model="formData.content"
  79. type="textarea"
  80. disabled
  81. :autosize="{ minRows: 5, maxRows: 8 }"
  82. placeholder="请输入通知内容"
  83. style="width: 500px"
  84. ></Input>
  85. </div>
  86. </FormItem>
  87. <FormItem label="状态" prop="is_sms">
  88. <RadioGroup v-model="formData.is_sms">
  89. <Radio :label="1">开启</Radio>
  90. <Radio :label="2">关闭</Radio>
  91. </RadioGroup>
  92. </FormItem>
  93. </div>
  94. <div v-else-if="item.slot === 'is_wechat' && !loading">
  95. <FormItem label="ID">
  96. <Input
  97. v-model="formData.templage_message_id"
  98. disabled
  99. placeholder="请输入通模板编号"
  100. style="width: 500px"
  101. ></Input>
  102. </FormItem>
  103. <FormItem label="模板编号">
  104. <Input
  105. v-model="formData.tempkey"
  106. disabled
  107. placeholder="请输入通模板编号"
  108. style="width: 500px"
  109. ></Input>
  110. </FormItem>
  111. <FormItem label="模板">
  112. <Input
  113. disabled
  114. v-model="formData.content"
  115. type="textarea"
  116. :autosize="{ minRows: 5, maxRows: 8 }"
  117. placeholder="请输入模板"
  118. style="width: 500px"
  119. ></Input>
  120. </FormItem>
  121. <FormItem label="模板ID">
  122. <Input
  123. v-model="formData.tempid"
  124. placeholder="请输入模板ID"
  125. style="width: 500px"
  126. ></Input>
  127. </FormItem>
  128. <FormItem label="状态" prop="is_wechat">
  129. <RadioGroup v-model="formData.is_wechat">
  130. <Radio :label="1">开启</Radio>
  131. <Radio :label="2">关闭</Radio>
  132. </RadioGroup>
  133. </FormItem>
  134. </div>
  135. <div v-else-if="item.slot === 'is_routine' && !loading">
  136. <FormItem label="ID">
  137. <Input
  138. v-model="formData.templage_message_id"
  139. disabled
  140. placeholder="请输入通模板编号"
  141. style="width: 500px"
  142. ></Input>
  143. </FormItem>
  144. <FormItem label="模板编号">
  145. <Input
  146. v-model="formData.tempkey"
  147. disabled
  148. placeholder="请输入通模板编号"
  149. style="width: 500px"
  150. ></Input>
  151. </FormItem>
  152. <FormItem label="模板">
  153. <Input
  154. disabled
  155. v-model="formData.content"
  156. type="textarea"
  157. :autosize="{ minRows: 5, maxRows: 8 }"
  158. placeholder="请输入模板"
  159. style="width: 500px"
  160. ></Input>
  161. </FormItem>
  162. <FormItem label="模板ID">
  163. <Input
  164. v-model="formData.tempid"
  165. placeholder="请输入模板ID"
  166. style="width: 500px"
  167. ></Input>
  168. </FormItem>
  169. <FormItem label="状态" prop="is_routine">
  170. <RadioGroup v-model="formData.is_routine">
  171. <Radio :label="1">开启</Radio>
  172. <Radio :label="2">关闭</Radio>
  173. </RadioGroup>
  174. </FormItem>
  175. </div>
  176. <div v-else-if="item.slot === 'is_ent_wechat' && !loading">
  177. <FormItem label="通知内容">
  178. <div class="content">
  179. <Input
  180. v-model="formData.ent_wechat_text"
  181. type="textarea"
  182. :autosize="{ minRows: 5, maxRows: 8 }"
  183. placeholder="请输入通知内容"
  184. style="width: 500px"
  185. ></Input>
  186. <div class="trip">
  187. <div>
  188. 请输入模板消息详细内容对应的变量。关键字个数需与已添加的模板一致。
  189. 可以使用如下变量:
  190. </div>
  191. <div
  192. v-for="(item, index) in formData.variable.split(',')"
  193. :key="index"
  194. >
  195. {{ item }}
  196. </div>
  197. </div>
  198. </div>
  199. </FormItem>
  200. <FormItem label="机器人链接">
  201. <div class="content">
  202. <Input
  203. v-model="formData.url"
  204. placeholder="请输入机器人链接"
  205. style="width: 500px"
  206. ></Input>
  207. <div class="trip">企业微信群机器人链接</div>
  208. </div>
  209. </FormItem>
  210. <FormItem label="状态" prop="is_ent_wechat">
  211. <RadioGroup v-model="formData.is_ent_wechat">
  212. <Radio :label="1">开启</Radio>
  213. <Radio :label="2">关闭</Radio>
  214. </RadioGroup>
  215. </FormItem>
  216. </div>
  217. <FormItem>
  218. <Button type="primary" @click="handleSubmit('formData')"
  219. >提交</Button
  220. >
  221. </FormItem>
  222. </Form>
  223. </TabPane>
  224. </Tabs>
  225. </Col>
  226. </Row>
  227. </div>
  228. </div>
  229. </template>
  230. <script>
  231. import {
  232. getNotificationInfo,
  233. getNotificationSave,
  234. } from "@/api/notification.js";
  235. export default {
  236. data() {
  237. return {
  238. tabs: [
  239. {
  240. title: "系统通知",
  241. slot: "is_system",
  242. },
  243. {
  244. title: "短信通知",
  245. slot: "is_sms",
  246. },
  247. {
  248. title: "微信模板消息",
  249. slot: "is_wechat",
  250. },
  251. {
  252. title: "微信小程序提醒",
  253. slot: "is_routine",
  254. },
  255. {
  256. title: "企业微信",
  257. slot: "is_ent_wechat",
  258. },
  259. ],
  260. tabsList: [],
  261. formData: {},
  262. id: 0,
  263. loading: true,
  264. ruleValidate: {
  265. name: [
  266. {
  267. required: true,
  268. message: "请输入通知场景",
  269. trigger: "blur",
  270. },
  271. ],
  272. title: [
  273. {
  274. required: true,
  275. message: "请输入通知场景",
  276. trigger: "blur",
  277. },
  278. ],
  279. content: [
  280. {
  281. required: true,
  282. message: "请输入通知内容",
  283. trigger: "blur",
  284. },
  285. ],
  286. },
  287. };
  288. },
  289. created() {
  290. this.id = this.$route.query.id;
  291. this.changeTabs("is_system");
  292. },
  293. methods: {
  294. changeTabs(name) {
  295. this.getData(this.id, name);
  296. },
  297. getData(id, name) {
  298. this.loading = true;
  299. this.formData = {};
  300. getNotificationInfo(id, name)
  301. .then((res) => {
  302. if (!this.tabsList.length) {
  303. this.tabs.map((v) => {
  304. if (res.data[v.slot]) {
  305. this.tabsList.push(v);
  306. }
  307. });
  308. }
  309. this.formData = res.data;
  310. this.formData.type = name;
  311. this.formData.id = id;
  312. this.loading = false;
  313. })
  314. .catch((err) => {
  315. this.$Message.error(err.msg);
  316. });
  317. },
  318. handleSubmit(name) {
  319. getNotificationSave(this.formData)
  320. .then((res) => {
  321. this.$Message.success("设置成功");
  322. })
  323. .catch((err) => {
  324. this.$Message.error(err);
  325. });
  326. },
  327. handleReset(name) {
  328. this.$emit("close");
  329. },
  330. },
  331. };
  332. </script>
  333. <style scoped>
  334. .edit {
  335. }
  336. .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-content {
  337. height: 120px;
  338. margin-top: -16px;
  339. }
  340. .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-content > .ivu-tabs-tabpane {
  341. background: #fff;
  342. padding: 16px;
  343. }
  344. .demo-tabs-style1 > .ivu-tabs.ivu-tabs-card > .ivu-tabs-bar .ivu-tabs-tab {
  345. border-color: transparent;
  346. }
  347. .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-bar .ivu-tabs-tab-active {
  348. border-color: #fff;
  349. }
  350. .tabs {
  351. padding: 0 30px;
  352. background-color: #fff;
  353. margin-top: 20px;
  354. }
  355. .trip {
  356. color: rgb(146, 139, 139);
  357. background-color: #f2f2f2;
  358. margin-left: 80px;
  359. border-radius: 4px;
  360. padding: 15px;
  361. }
  362. .content {
  363. display: flex;
  364. }
  365. .form-sty {
  366. margin-top: 20px;
  367. }
  368. </style>