InspectPlanModal.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <u-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. contentFull
  6. @ok="handleOk"
  7. @cancel="handleCancel">
  8. <template slot="centerContent">
  9. <div class="tabs">
  10. <span v-for="(item, index) in tabs" :key="index" @click="handleTab(item.key)" class="item" :class="item.key === chooseTab ? 'choose':''">{{ item.name }}</span>
  11. </div>
  12. </template>
  13. <inspect-plan-form-set v-show="chooseTab==='set'" ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></inspect-plan-form-set>
  14. <inspect-plan-form-list v-show="chooseTab==='list'" ref="realList" @ok="submitCallback"></inspect-plan-form-list>
  15. </u-modal>
  16. </template>
  17. <script>
  18. import InspectPlanFormList from './InspectPlanFormList.vue'
  19. import InspectPlanFormSet from './InspectPlanFormSet'
  20. export default {
  21. name: 'InspectPlanModal',
  22. components: {
  23. InspectPlanFormSet,
  24. InspectPlanFormList
  25. },
  26. data () {
  27. return {
  28. title:'',
  29. width:800,
  30. visible: false,
  31. disableSubmit: false,
  32. tabs: [
  33. { name: '计划设置', key: 'set' },
  34. { name: '计划内容', key: 'list' },
  35. ],
  36. chooseTab: 'set'
  37. }
  38. },
  39. methods: {
  40. handleTab(key){
  41. console.log(key)
  42. this.chooseTab = key
  43. },
  44. add () {
  45. this.visible=true
  46. this.$nextTick(()=>{
  47. this.$refs.realForm.add();
  48. this.$refs.realList.add();
  49. })
  50. },
  51. edit (record) {
  52. this.visible=true
  53. this.$nextTick(()=>{
  54. this.$refs.realForm.edit(record);
  55. this.$refs.realList.edit(record);
  56. })
  57. },
  58. close () {
  59. this.$emit('close');
  60. this.visible = false;
  61. },
  62. handleOk () {
  63. this.$refs.realForm.submitForm();
  64. },
  65. submitCallback(){
  66. this.$emit('ok');
  67. this.visible = false;
  68. },
  69. handleCancel () {
  70. this.close()
  71. },
  72. }
  73. }
  74. </script>
  75. <style lang="less" scoped>
  76. .tabs{
  77. .item{
  78. font-size: 15px;
  79. cursor: pointer;
  80. }
  81. .item:first-child{
  82. margin-right: 22px;
  83. }
  84. .choose{
  85. color: #1890FF;
  86. }
  87. }
  88. </style>