add.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view style="padding: 20rpx;">
  3. <view style="padding: 30rpx;background-color: white;border-radius:50rpx">
  4. <u--form labelPosition="left" :model="formData" ref="uForm" labelWidth='120'>
  5. <u-form-item label="制衣生产车间:" prop="workshopInfo.zyProductWorkshop" borderBottom ref="uItem"
  6. :required="true">
  7. <u--input v-model="formData.workshopInfo.zyProductWorkshop" placeholder="请输入生产车间" border="none"></u--input>
  8. </u-form-item>
  9. <u-form-item label="启用:" prop="workshopInfo.status" borderBottom ref="uItem" v-show="adminType">
  10. <u-switch v-model="formData.workshopInfo.status"></u-switch>
  11. </u-form-item>
  12. <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
  13. <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
  14. </u--form>
  15. </view>
  16. <u-toast ref="uToast"></u-toast>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. add
  22. } from '@/api/biz/workshop.js'
  23. import { getToken, setToken, removeToken,getAdminType,setAdminType,removeAdminType } from '@/utils/auth'
  24. export default {
  25. data() {
  26. return {
  27. formData: {
  28. workshopInfo: {
  29. zyProductWorkshop: '',
  30. // zyTeam: '',
  31. // orderNo: '',
  32. // deliveryDate: "",
  33. status: false
  34. }
  35. },
  36. deliveryDateShowFlag: false,
  37. rules: {
  38. 'workshopInfo.zyProductWorkshop': {
  39. type: 'string',
  40. required: true,
  41. message: '请填写制衣生产车间',
  42. trigger: ['blur', 'change']
  43. }
  44. // 'workshopInfo.zyTeam': {
  45. // type: 'string',
  46. // required: true,
  47. // message: '请填写制衣班组',
  48. // trigger: ['blur', 'change']
  49. // },
  50. // 'workshopInfo.orderNo': {
  51. // type: 'string',
  52. // required: true,
  53. // message: '请填写订单号',
  54. // trigger: ['blur', 'change']
  55. // },
  56. // 'workshopInfo.deliveryDate': {
  57. // type: 'string',
  58. // required: true,
  59. // message: '请填写交期',
  60. // trigger: ['blur', 'change']
  61. // }
  62. },
  63. adminType:false
  64. }
  65. },
  66. onLoad() {
  67. },
  68. onReady() {
  69. this.$refs.uForm.setRules(this.rules)
  70. this.adminType = this.$store.state.user.adminType
  71. console.log(getAdminType())
  72. },
  73. methods: {
  74. confirm(e) {
  75. console.log(e);
  76. this.deliveryDateShowFlag = false
  77. this.formData.workshopInfo.deliveryDate = e[0]
  78. },
  79. submit() {
  80. this.$refs.uForm.validate().then(val => {
  81. add(this.formData.workshopInfo).then(res => {
  82. if (res.success) {
  83. this.$refs.uToast.show({
  84. type: 'success',
  85. message: "新增成功",
  86. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  87. })
  88. this.reset()
  89. } else {
  90. this.$refs.uToast.show({
  91. type: 'error',
  92. message: res.message,
  93. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
  94. })
  95. }
  96. })
  97. })
  98. },
  99. reset() {
  100. this.formData = {
  101. workshopInfo: {
  102. zyProductWorkshop: '',
  103. // zyTeam: '',
  104. // orderNo: '',
  105. // deliveryDate: "",
  106. // status: true
  107. }
  108. }
  109. this.$refs.uForm.clearValidate()
  110. }
  111. },
  112. onUnload() {
  113. uni.$emit('loadData');
  114. }
  115. }
  116. </script>
  117. <style>
  118. </style>