| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <template>
- <div class="edit">
- <div class="i-layout-page-header">
- <router-link :to="{ path: '/admin/setting/notification/index' }"
- ><Button icon="ios-arrow-back" size="small" type="text"
- >返回</Button
- ></router-link
- >
- <Divider type="vertical" />
- <span class="ivu-page-header-title">{{ $route.meta.title }}</span>
- </div>
- <div class="tabs">
- <Row :gutter="32">
- <Col span="32" class="demo-tabs-style1" style="padding: 16px">
- <Tabs @on-click="changeTabs">
- <TabPane
- v-for="(item, index) in tabsList"
- :key="index"
- :name="item.slot"
- :label="item.title"
- >
- <Form
- class="form-sty"
- ref="formData"
- :model="formData"
- :rules="ruleValidate"
- :label-width="80"
- >
- <div v-if="item.slot === 'is_system' && !loading">
- <FormItem label="通知标题">
- <Input
- v-model="formData.system_title"
- placeholder="请输入通知标题"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="通知内容">
- <div class="content">
- <Input
- v-model="formData.system_text"
- type="textarea"
- :autosize="{ minRows: 5, maxRows: 8 }"
- placeholder="请输入通知内容"
- style="width: 500px"
- ></Input>
- <div class="trip">
- <div>
- 请输入模板消息详细内容对应的变量。关键字个数需与已添加的模板一致。
- 可以使用如下变量:
- </div>
- <div
- v-for="(item, index) in formData.variable.split(',')"
- :key="index"
- >
- {{ item }}
- </div>
- </div>
- </div>
- </FormItem>
- <FormItem label="状态" prop="is_system">
- <RadioGroup v-model="formData.is_system">
- <Radio :label="1">开启</Radio>
- <Radio :label="2">关闭</Radio>
- </RadioGroup>
- </FormItem>
- </div>
- <div v-if="item.slot === 'is_sms' && !loading">
- <FormItem label="短信模版ID">
- <Input
- v-model="formData.sms_id"
- placeholder="短信模版ID"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="通知内容">
- <div class="content">
- <Input
- v-model="formData.content"
- type="textarea"
- disabled
- :autosize="{ minRows: 5, maxRows: 8 }"
- placeholder="请输入通知内容"
- style="width: 500px"
- ></Input>
- </div>
- </FormItem>
- <FormItem label="状态" prop="is_sms">
- <RadioGroup v-model="formData.is_sms">
- <Radio :label="1">开启</Radio>
- <Radio :label="2">关闭</Radio>
- </RadioGroup>
- </FormItem>
- </div>
- <div v-else-if="item.slot === 'is_wechat' && !loading">
- <FormItem label="ID">
- <Input
- v-model="formData.templage_message_id"
- disabled
- placeholder="请输入通模板编号"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板编号">
- <Input
- v-model="formData.tempkey"
- disabled
- placeholder="请输入通模板编号"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板">
- <Input
- disabled
- v-model="formData.content"
- type="textarea"
- :autosize="{ minRows: 5, maxRows: 8 }"
- placeholder="请输入模板"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板ID">
- <Input
- v-model="formData.tempid"
- placeholder="请输入模板ID"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="状态" prop="is_wechat">
- <RadioGroup v-model="formData.is_wechat">
- <Radio :label="1">开启</Radio>
- <Radio :label="2">关闭</Radio>
- </RadioGroup>
- </FormItem>
- </div>
- <div v-else-if="item.slot === 'is_routine' && !loading">
- <FormItem label="ID">
- <Input
- v-model="formData.templage_message_id"
- disabled
- placeholder="请输入通模板编号"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板编号">
- <Input
- v-model="formData.tempkey"
- disabled
- placeholder="请输入通模板编号"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板">
- <Input
- disabled
- v-model="formData.content"
- type="textarea"
- :autosize="{ minRows: 5, maxRows: 8 }"
- placeholder="请输入模板"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="模板ID">
- <Input
- v-model="formData.tempid"
- placeholder="请输入模板ID"
- style="width: 500px"
- ></Input>
- </FormItem>
- <FormItem label="状态" prop="is_routine">
- <RadioGroup v-model="formData.is_routine">
- <Radio :label="1">开启</Radio>
- <Radio :label="2">关闭</Radio>
- </RadioGroup>
- </FormItem>
- </div>
- <div v-else-if="item.slot === 'is_ent_wechat' && !loading">
- <FormItem label="通知内容">
- <div class="content">
- <Input
- v-model="formData.ent_wechat_text"
- type="textarea"
- :autosize="{ minRows: 5, maxRows: 8 }"
- placeholder="请输入通知内容"
- style="width: 500px"
- ></Input>
- <div class="trip">
- <div>
- 请输入模板消息详细内容对应的变量。关键字个数需与已添加的模板一致。
- 可以使用如下变量:
- </div>
- <div
- v-for="(item, index) in formData.variable.split(',')"
- :key="index"
- >
- {{ item }}
- </div>
- </div>
- </div>
- </FormItem>
- <FormItem label="机器人链接">
- <div class="content">
- <Input
- v-model="formData.url"
- placeholder="请输入机器人链接"
- style="width: 500px"
- ></Input>
- <div class="trip">企业微信群机器人链接</div>
- </div>
- </FormItem>
- <FormItem label="状态" prop="is_ent_wechat">
- <RadioGroup v-model="formData.is_ent_wechat">
- <Radio :label="1">开启</Radio>
- <Radio :label="2">关闭</Radio>
- </RadioGroup>
- </FormItem>
- </div>
- <FormItem>
- <Button type="primary" @click="handleSubmit('formData')"
- >提交</Button
- >
- </FormItem>
- </Form>
- </TabPane>
- </Tabs>
- </Col>
- </Row>
- </div>
- </div>
- </template>
- <script>
- import {
- getNotificationInfo,
- getNotificationSave,
- } from "@/api/notification.js";
- export default {
- data() {
- return {
- tabs: [
- {
- title: "系统通知",
- slot: "is_system",
- },
- {
- title: "短信通知",
- slot: "is_sms",
- },
- {
- title: "微信模板消息",
- slot: "is_wechat",
- },
- {
- title: "微信小程序提醒",
- slot: "is_routine",
- },
- {
- title: "企业微信",
- slot: "is_ent_wechat",
- },
- ],
- tabsList: [],
- formData: {},
- id: 0,
- loading: true,
- ruleValidate: {
- name: [
- {
- required: true,
- message: "请输入通知场景",
- trigger: "blur",
- },
- ],
- title: [
- {
- required: true,
- message: "请输入通知场景",
- trigger: "blur",
- },
- ],
- content: [
- {
- required: true,
- message: "请输入通知内容",
- trigger: "blur",
- },
- ],
- },
- };
- },
- created() {
- this.id = this.$route.query.id;
- this.changeTabs("is_system");
- },
- methods: {
- changeTabs(name) {
- this.getData(this.id, name);
- },
- getData(id, name) {
- this.loading = true;
- this.formData = {};
- getNotificationInfo(id, name)
- .then((res) => {
- if (!this.tabsList.length) {
- this.tabs.map((v) => {
- if (res.data[v.slot]) {
- this.tabsList.push(v);
- }
- });
- }
- this.formData = res.data;
- this.formData.type = name;
- this.formData.id = id;
- this.loading = false;
- })
- .catch((err) => {
- this.$Message.error(err.msg);
- });
- },
- handleSubmit(name) {
- getNotificationSave(this.formData)
- .then((res) => {
- this.$Message.success("设置成功");
- })
- .catch((err) => {
- this.$Message.error(err);
- });
- },
- handleReset(name) {
- this.$emit("close");
- },
- },
- };
- </script>
- <style scoped>
- .edit {
- }
- .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-content {
- height: 120px;
- margin-top: -16px;
- }
- .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-content > .ivu-tabs-tabpane {
- background: #fff;
- padding: 16px;
- }
- .demo-tabs-style1 > .ivu-tabs.ivu-tabs-card > .ivu-tabs-bar .ivu-tabs-tab {
- border-color: transparent;
- }
- .demo-tabs-style1 > .ivu-tabs-card > .ivu-tabs-bar .ivu-tabs-tab-active {
- border-color: #fff;
- }
- .tabs {
- padding: 0 30px;
- background-color: #fff;
- margin-top: 20px;
- }
- .trip {
- color: rgb(146, 139, 139);
- background-color: #f2f2f2;
- margin-left: 80px;
- border-radius: 4px;
- padding: 15px;
- }
- .content {
- display: flex;
- }
- .form-sty {
- margin-top: 20px;
- }
- </style>
|