| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <template>
- <el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" :label-width="$i18n.locale === 'en-US' ? '120px' : '80px'">
- <el-form-item label="用户id" prop="customerId">
- <el-input v-model="dataForm.customerId" placeholder="用户id"></el-input>
- </el-form-item>
- <el-form-item label="所属公司" prop="companyId">
- <el-select v-model="dataForm.companyId" placeholder="请选择公司">
- <el-option
- v-for="item in companys"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="回访类型" prop="callType">
- <el-select v-model="dataForm.callType" placeholder="回访类型">
- <el-option
- v-for="item in callTypes"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="推送内容" prop="content">
- <el-input v-model="dataForm.content" placeholder="推送内容"></el-input>
- </el-form-item>
- <el-form-item label="备注" prop="remark">
- <el-input v-model="dataForm.remark" placeholder="备注"></el-input>
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-select v-model="dataForm.status" placeholder="状态">
- <el-option
- v-for="item in statusList"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <template slot="footer">
- <el-button @click="visible = false">{{ $t('cancel') }}</el-button>
- <el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button>
- </template>
- </el-dialog>
- </template>
-
- <script>
- import debounce from 'lodash/debounce'
- export default {
- data () {
- return {
- visible: false,
- dataForm: {
- id: '',
- customerId: '',
- companyId: '',
- callType: '',
- content: '',
- remark: '',
- isPush: '',
- pushCode: '',
- pushMsg: '',
- pushDate: '',
- createBy: '',
- createTime: '',
- updateBy: '',
- updateTime: '',
- deleteTime: '',
- status: ''
- },
- companys:[],
- callTypes:[
- {
- 'label':'未回访',
- 'value':'0',
- },
- {
- 'label':'有效表单',
- 'value':'1',
- }
- ],
- statusList:[
- {
- 'label':'无效',
- 'value':0,
- },
- {
- 'label':'有效',
- 'value':1,
- }
- ],
- }
- },
- computed: {
- dataRule () {
- return {
- customerId: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- companyId: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- callType: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- content: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- remark: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ],
- status: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
- ]
- }
- }
- },
- methods: {
- init () {
- this.getCompanysOptions();
- this.visible = true
- this.$nextTick(() => {
- this.$refs['dataForm'].resetFields()
- if (this.dataForm.id) {
- this.getInfo()
- }
- })
- },
- // 获取信息
- getInfo () {
- this.$http.get(`/sys/callback/${this.dataForm.id}`).then(({ data: res }) => {
- if (res.code !== 0) {
- return this.$message.error(res.msg)
- }
- this.dataForm = {
- ...this.dataForm,
- ...res.data
- }
- }).catch(() => {})
- },
- //初始化公司下拉框中的选项
- async getCompanysOptions() {
- this.$http.get(`/sys/companies/list`).then(({ data: res }) => {
- if (res.code !== 0) {
- return this.$message.error(res.msg)
- }
- this.companys=[];
- if (res.data!=null){
- res.data.forEach(element => {
- this.companys.push({label:element.name,value:element.id})
- })
- }
- }).catch(() => {})
- },
- // 表单提交
- dataFormSubmitHandle: debounce(function () {
- this.$refs['dataForm'].validate((valid) => {
- if (!valid) {
- return false
- }
- this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/callback/', this.dataForm).then(({ data: res }) => {
- if (res.code !== 0) {
- return this.$message.error(res.msg)
- }
- this.$message({
- message: this.$t('prompt.success'),
- type: 'success',
- duration: 500,
- onClose: () => {
- this.visible = false
- this.$emit('refreshDataList')
- }
- })
- }).catch(() => {})
- })
- }, 1000, { 'leading': true, 'trailing': false })
- }
- }
- </script>
|