materialDetail.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="container">
  3. <uni-popup ref="editDialog" type="dialog">
  4. <view class="popup">
  5. <uni-card :is-shadow="false" is-full>
  6. <text class="uni-h6">修正原料</text>
  7. </uni-card>
  8. <uni-forms class="form" :modelValue="material">
  9. <uni-forms-item label="料筒" name="id">
  10. <uni-data-select v-model="material.id" :localdata="rangeIds"></uni-data-select>
  11. </uni-forms-item>
  12. <uni-forms-item label="产品" name="name">
  13. <uni-data-select v-model="material.name" :localdata="rangeNames"></uni-data-select>
  14. </uni-forms-item>
  15. <uni-forms-item label="原料剩余" name="surplus">
  16. <uni-data-select v-model="material.surplus" :localdata="rangeSurplus"></uni-data-select>
  17. </uni-forms-item>
  18. <uni-forms-item label="换料规格" name="specs">
  19. <uni-data-select v-model="material.specs" :localdata="rangeSpecs"></uni-data-select>
  20. </uni-forms-item>
  21. <uni-forms-item label="到期日期" name="date">
  22. <uni-data-select v-model="material.date" :localdata="rangeDates"></uni-data-select>
  23. </uni-forms-item>
  24. </uni-forms>
  25. <view class="button-group">
  26. <button @click="update" type="primary" size="mini">确定</button>
  27. <button @click="close" type="primary" size="mini">关闭</button>
  28. </view>
  29. </view>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. const util = require("@/utils/util.js");
  35. const api = require('@/utils/api.js');
  36. export default {
  37. data() {
  38. return {
  39. rangeIds: [{
  40. value: 1,
  41. text: "1"
  42. },
  43. {
  44. value: 2,
  45. text: "2"
  46. },
  47. {
  48. value: 3,
  49. text: "3"
  50. }
  51. ],
  52. rangeNames: [{
  53. value: "燕麦",
  54. text: "燕麦"
  55. },
  56. {
  57. value: "魔芋粉",
  58. text: "魔芋粉"
  59. },
  60. {
  61. value: "红薯粉",
  62. text: "红薯粉"
  63. }
  64. ],
  65. rangeSurplus: [{
  66. value: 1,
  67. text: "5"
  68. },
  69. {
  70. value: 2,
  71. text: "10"
  72. },
  73. {
  74. value: 3,
  75. text: "20"
  76. }
  77. ],
  78. rangeSpecs: [{
  79. value: 1,
  80. text: "5"
  81. },
  82. {
  83. value: 2,
  84. text: "10"
  85. },
  86. {
  87. value: 3,
  88. text: "20"
  89. }
  90. ],
  91. rangeDates: [{
  92. value: "2021-11-14",
  93. text: "2021-11-14"
  94. },
  95. {
  96. value: "2021-12-24",
  97. text: "2021-12-24"
  98. },
  99. {
  100. value: "2022-08-01",
  101. text: "2022-08-01"
  102. }
  103. ],
  104. material: {
  105. id: '',
  106. name: '',
  107. surplus: '',
  108. specs: '',
  109. date: '',
  110. status: ''
  111. },
  112. }
  113. },
  114. props: {
  115. dialogVisible: {
  116. type: Boolean,
  117. default: false,
  118. }
  119. },
  120. computed: {
  121. isVisible: {
  122. get() {
  123. return this.dialogVisible
  124. },
  125. set() {
  126. this.close()
  127. }
  128. }
  129. },
  130. methods: {
  131. setMaterial(row) {
  132. if (row) {
  133. this.material = {
  134. ...row
  135. }
  136. }
  137. this.$refs.editDialog.open();
  138. },
  139. close() {
  140. this.$refs.editDialog.close();
  141. },
  142. update() {
  143. util.request(api.MaterialUpdate, this.material, "POST", "application/json").then(function(res) {
  144. if (res.errno === 0) {
  145. uni.showToast({
  146. title: res.data,
  147. icon: 'success',
  148. duration: 2000,
  149. complete: function() {
  150. setTimeout(function() {
  151. uni.switchTab({
  152. url: '/pages/material/material',
  153. });
  154. }, 2000)
  155. }
  156. });
  157. } else {
  158. util.toast(res.data);
  159. }
  160. });
  161. }
  162. },
  163. }
  164. </script>
  165. <style type="scss">
  166. .form {
  167. padding: 10px;
  168. background-color: #fff;
  169. width: 640rpx;
  170. }
  171. .popup {
  172. display: block;
  173. overflow: hidden;
  174. background-color: #fff;
  175. }
  176. .button-group {
  177. margin-bottom: 20rpx;
  178. display: flex;
  179. justify-content: space-around;
  180. }
  181. </style>
  182. <style scoped>
  183. /deep/ .form .uni-forms-item__label {
  184. min-width: 140rpx;
  185. height: 60rpx;
  186. }
  187. </style>