ModifySaller.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="modify-saller-wrap">
  3. <el-form
  4. :model="ruleForm"
  5. :rules="rules"
  6. ref="ruleForm"
  7. label-width="100px"
  8. class="demo-ruleForm"
  9. >
  10. <el-form-item label="商家名称">
  11. <span>{{data.BusinessName||''}}</span>
  12. </el-form-item>
  13. <el-form-item label="当前销售">
  14. <span>{{data.SellerName||''}}</span>
  15. </el-form-item>
  16. <el-form-item label="移至销售" prop="saller">
  17. <el-cascader
  18. ref="cascader"
  19. v-model="ruleForm.saller"
  20. :options="salesArr"
  21. :show-all-levels="false"
  22. :props="{
  23. expandTrigger: 'hover',
  24. children: 'Child',
  25. emitPath: false,
  26. label:'AdminName',
  27. value:'AdminId',
  28. }"
  29. collapse-tags
  30. filterable
  31. clearable
  32. placeholder="请选择销售"
  33. />
  34. </el-form-item>
  35. <div style="text-align:center;margin:30px 0">
  36. <el-button type="primary" plain @click="handleClose">取消</el-button>
  37. <el-button type="primary" @click="handleSave">保存</el-button>
  38. </div>
  39. </el-form>
  40. </div>
  41. </template>
  42. <script>
  43. export default {
  44. props:{
  45. salesArr:{ //销售数据
  46. type:Array,
  47. default:()=>{return []}
  48. },
  49. data:{ //正在编辑的数据
  50. type:Object,
  51. default:()=>{return {}}
  52. }
  53. },
  54. data() {
  55. return {
  56. salesArr:[],
  57. rules:{
  58. saller:[{required: true, message: '请选择所属销售', trigger: 'change' },],
  59. },
  60. ruleForm:{
  61. saller:''
  62. }
  63. }
  64. },
  65. created() {},
  66. methods: {
  67. handleSave(){
  68. this.$refs.ruleForm.validate((valid)=>{
  69. if(valid){
  70. const cascaderNodes = this.$refs.cascader.getCheckedNodes({leafOnly:true})
  71. this.$emit('modifySaller',{
  72. saller:Number(cascaderNodes[0]?cascaderNodes[0].value:0),
  73. sallerName:cascaderNodes[0]?cascaderNodes[0].label:''
  74. })
  75. this.initForm()
  76. }
  77. })
  78. },
  79. initForm(){
  80. this.ruleForm.saller = ''
  81. this.$refs.ruleForm.resetFields();
  82. },
  83. handleClose(){
  84. this.initForm()
  85. this.$emit('close')
  86. },
  87. },
  88. }
  89. </script>
  90. <style>
  91. </style>