| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <template>
- <a-spin :spinning="confirmLoading">
- <j-form-container :disabled="formDisabled">
- <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
- <a-row>
- <a-col :span="24">
- <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workNo">
- <a-input v-model="model.workNo" placeholder="请输入编号" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
- <a-input v-model="model.name" placeholder="请输入姓名" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="职务" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="postId">
- <!-- <a-input v-model="model.operatorId" placeholder="请选择职务" ></a-input>-->
- <a-select
- mode="multiple"
- v-model="model.postId"
- placeholder="请选择职务"
- :allowClear="true"
- >
- <a-select-option :value="item.id" v-for="(item,index) in postList" :key="index">{{ item.itemText }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="关联操作用户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operatorId">
- <!-- <a-input v-model="model.operatorId" placeholder="请选择关联操作用户" ></a-input>-->
- <a-select
- v-model="model.operatorId"
- placeholder="请选择关联操作用户"
- :allowClear="true"
- >
- <a-select-option :value="item.id" v-for="(item,index) in userList" :key="index">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mobile">
- <a-input v-model="model.mobile" placeholder="请输入联系电话" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="手机号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phone">
- <a-input v-model="model.phone" placeholder="请输入手机号" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
- <a-input v-model="model.address" placeholder="请输入地址" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item label="备注信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
- <a-input v-model="model.remarks" placeholder="请输入备注信息" ></a-input>
- </a-form-model-item>
- </a-col>
- <a-col :span="24">
- <a-form-model-item
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- label="是否有效"
- prop="status">
- <a-switch checkedChildren="有效" unCheckedChildren="无效" v-model="model.status"/>
- </a-form-model-item>
- </a-col>
- </a-row>
- </a-form-model>
- </j-form-container>
- </a-spin>
- </template>
- <script>
- import { httpAction, getAction } from '@/api/manage'
- import { validateDuplicateValue } from '@/utils/util'
- export default {
- name: 'BusSalesPersonForm',
- components: {
- },
- props: {
- //表单禁用
- disabled: {
- type: Boolean,
- default: false,
- required: false
- }
- },
- data () {
- return {
- model:{
- },
- labelCol: {
- xs: { span: 24 },
- sm: { span: 5 },
- },
- wrapperCol: {
- xs: { span: 24 },
- sm: { span: 16 },
- },
- confirmLoading: false,
- validatorRules: {
- workNo: [
- { required: true, message: '请输入编号!'},
- ],
- name: [
- { required: true, message: '请输入姓名!'},
- ],
- phone: [
- { required: true, message: '请输入手机号!'},
- ],
- status: [
- { required: true, message: '请选择服务员是否有效!'},
- ],
- },
- url: {
- add: "/business/busSalesPerson/add",
- edit: "/business/busSalesPerson/edit",
- queryById: "/business/busSalesPerson/queryById"
- },
- userList:[],
- postList:[]
- }
- },
- computed: {
- formDisabled(){
- return this.disabled
- },
- },
- created () {
- //备份model原始值
- this.modelDefault = JSON.parse(JSON.stringify(this.model));
- this.getHotelPost()
- },
- methods: {
- add () {
- this.edit(this.modelDefault);
- this.edit({status:true });
- },
- edit (record) {
- if (record.status == 1){
- record.status = true;
- }else {
- record.status = false;
- }
- record.postId = record.postIds.split(',');
- this.model = Object.assign({}, record);
- this.visible = true;
- },
- submitForm () {
- const that = this;
- // 触发表单验证
- this.$refs.form.validate(valid => {
- if (valid) {
- that.confirmLoading = true;
- let httpurl = '';
- let method = '';
- if(!this.model.id){
- httpurl+=this.url.add;
- var info = JSON.parse(localStorage.getItem("storeInfo"));
- this.model.hotelId = info.id;
- method = 'post';
- }else{
- httpurl+=this.url.edit;
- method = 'put';
- }
- var _model = this.model;
- if (_model.status){
- _model.status = 1;
- }else {
- _model.status = 0;
- }
- _model.postIds = this.model.postId.join(",")
- console.log(_model)
- this.$delete( _model, 'postId')
- httpAction(httpurl,_model,method).then((res)=>{
- if(res.success){
- that.$message.success(res.message);
- that.$emit('ok');
- }else{
- that.$message.warning(res.message);
- }
- }).finally(() => {
- that.confirmLoading = false;
- })
- }
- })
- },
- getHotelPost(){
- var that = this;
- var param = {
- dictName:'职务'
- }
- // var values = JSON.parse(JSON.stringify(param))
- that.confirmLoading = true;
- getAction('/business/busDictItem/queryList',param).then((res)=>{
- console.log(res)
- if(res.success){
- if (res.code == 200 && res.result) {
- this.postList = res.result;
- }
- }
- }).finally(() => {
- that.confirmLoading = false;
- })
- }
- }
- }
- </script>
|