add.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view class="bg-f9 productionPlan">
  3. <header-bar :title="submitType === 'add' ? '计划详情' : '计划详情'"></header-bar>
  4. <view class="commons-dtl-box">
  5. <view class="">
  6. <span>产品名称</span> 3ml 注射器
  7. </view>
  8. <view class="">
  9. <span>计划数量</span> 8000
  10. </view>
  11. <view class="">
  12. <span>完成期限</span> 2023-10-1
  13. </view>
  14. </view>
  15. <view class="example" >
  16. <!-- 基础用法,不包含校验规则 -->
  17. <uni-forms label-position="top" :modelValue="form" label-width="130" ref="form" :rules="rules">
  18. <uni-forms-item label="指派人员" required name="type">
  19. <uni-data-select v-model="form.type" :localdata="types"></uni-data-select>
  20. </uni-forms-item>
  21. <uni-forms-item label="计划工序" required name="type">
  22. <uni-data-select v-model="form.type" :localdata="types"></uni-data-select>
  23. </uni-forms-item>
  24. <uni-forms-item label="生产数量" required>
  25. <uni-easyinput v-model="form.code" placeholder="请输入生产数量" />
  26. </uni-forms-item>
  27. <uni-forms-item label="计划开始时间" required name="unit">
  28. <uni-datetime-picker v-model="form.classifyId" />
  29. </uni-forms-item>
  30. <uni-forms-item label="计划完成时间" required name="unit">
  31. <uni-datetime-picker v-model="form.classifyId" />
  32. </uni-forms-item>
  33. </uni-forms>
  34. </view>
  35. <view class="common-add-list-btn" >
  36. + 添加计划明细
  37. </view>
  38. <view style="height:200rpx">
  39. </view>
  40. <button class="submit" @click="submitForm">提交</button>
  41. </view>
  42. </template>
  43. <script>
  44. import headerBar from '../../../components/header-bar/index.vue'
  45. import Vue from 'vue'
  46. export default {
  47. components: {
  48. headerBar
  49. },
  50. data() {
  51. return {
  52. form: {
  53. name: '',
  54. type: null,
  55. classifyId: null,
  56. code: null,
  57. unit: null,
  58. introduce: null,
  59. },
  60. types: [{
  61. text: '半成品',
  62. value: '0'
  63. }, {
  64. text: '成品',
  65. value: '1'
  66. }],
  67. rules: {
  68. // 对name字段进行必填验证
  69. name: {
  70. rules: [{
  71. required: true,
  72. errorMessage: '请输入产品名称',
  73. }, ]
  74. },
  75. // 对email字段进行必填验证
  76. type: {
  77. rules: [{
  78. required: true,
  79. errorMessage: '请选择产品类型',
  80. }, ]
  81. },
  82. unit: {
  83. rules: [{
  84. required: true,
  85. errorMessage: '请输入产品单位',
  86. }, ]
  87. },
  88. classifyId: {
  89. rules: [{
  90. required: true,
  91. errorMessage: '请选择产品分类',
  92. }, ]
  93. },
  94. },
  95. submitType: 'add',
  96. treeData: [],
  97. }
  98. },
  99. onLoad(e) {
  100. if (e.id) {
  101. this.form.id = e.id
  102. this.form.remarks = e.remarks
  103. this.form.type = e.type
  104. this.form.name = e.name
  105. this.submitType = 'edit'
  106. }
  107. this.getTree()
  108. },
  109. methods: {
  110. treeChange() {},
  111. getTree() {
  112. const v = this
  113. v.$post('/api/basics//classify/tree', {
  114. type: 1
  115. }).then(res => {
  116. if (res.code === 200) {
  117. v.treeData = res.data
  118. }
  119. })
  120. },
  121. submitForm() {
  122. const v = this
  123. this.$refs.form.validate().then(res => {
  124. uni.showLoading({
  125. title: '加载中'
  126. });
  127. v.$post('/api/syringe-management/product/' + this.submitType, v.form).then(res => {
  128. if (res.code === 200) {
  129. uni.showToast({
  130. title: this.submitType == 'add' ? '添加成功' : '修改成功',
  131. duration: 1000,
  132. icon: 'success'
  133. })
  134. }
  135. uni.hideLoading()
  136. let pages = getCurrentPages(); // 获取页面栈
  137. let prePage = pages[pages.length - 2]; //获取上一页
  138. prePage.$vm.needRefresh = true; // 需要刷新
  139. setTimeout(() => {
  140. uni.navigateBack(1)
  141. }, 1000)
  142. })
  143. }).catch(err => {
  144. console.log('表单错误信息:', err);
  145. })
  146. },
  147. },
  148. }
  149. </script>
  150. <style lang="less">
  151. </style>