edit.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="edit-page">
  3. <navigation title="换模"></navigation>
  4. <view class="form-box">
  5. <u--form labelPosition="left" labelWidth="160rpx" :model="info" :rules="rules" ref="form">
  6. <view class="form">
  7. <u-form-item label="安装设备" borderBottom>
  8. <u--input v-model="equipmentName" placeholder="安装设备" border="none" disabled
  9. disabledColor="#fff">
  10. </u--input>
  11. </u-form-item>
  12. <u-form-item label="模具名称" prop="modulId" borderBottom>
  13. <inputSearch emptyTips="无匹配选项" :isJSON="true" :keyName="keyName" placeholder="请选择模具"
  14. :candidates="mouldActions" @getValue="mouldSelect" @clearInputValue="clearInputValue"></inputSearch>
  15. </u-form-item>
  16. <u-form-item label="产品名称" prop="productionId" borderBottom>
  17. <uni-data-select v-model="info.productionId" :localdata="productionActions" placeholder="请选择产品">
  18. </uni-data-select>
  19. </u-form-item>
  20. <u-form-item label="每模产品数" prop="productionMultiple" borderBottom>
  21. <u-number-box v-model="info.productionMultiple"></u-number-box>
  22. </u--input>
  23. </u-form-item>
  24. <u-form-item label="安装时间" prop="startTime" @click="showTimePicker = true">
  25. <u--input v-model="info.startTime" placeholder="请选择安装时间" border="none" disabled
  26. disabledColor="#ffffff"></u--input>
  27. </u-form-item>
  28. </view>
  29. </u--form>
  30. <u-datetime-picker :show="showTimePicker" v-model="defaultTime" mode="datetime"
  31. @cancel="showTimePicker=false" @confirm="timePickerConfirm($event)"></u-datetime-picker>
  32. </view>
  33. <view class="submit">
  34. <u-button @click="onSubmit" type="primary">提交</u-button>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import inputSearch from "@/components/inputSearch.vue";
  40. export default {
  41. components: {
  42. inputSearch
  43. },
  44. data() {
  45. return {
  46. showTimePicker: false,
  47. defaultTime: Number(new Date()),
  48. equipmentName: '',
  49. mouldActions: [],
  50. keyName: 'mouldName',
  51. productionActions: [],
  52. info: {
  53. id: '',
  54. modulId: '',
  55. productionId: '',
  56. productionMultiple: 1,
  57. startTime: ''
  58. },
  59. rules: {
  60. modulId: {
  61. type: 'number',
  62. required: true,
  63. message: '请选择模具',
  64. trigger: ['blur', 'change']
  65. },
  66. productionId: {
  67. type: 'number',
  68. required: true,
  69. message: '请选择产品',
  70. trigger: ['blur', 'change']
  71. },
  72. productionMultiple: {
  73. type: 'number',
  74. required: true,
  75. message: '请填写每模产品数',
  76. trigger: ['blur', 'change']
  77. },
  78. startTime: {
  79. type: 'string',
  80. required: true,
  81. message: '请选择安装时间',
  82. trigger: ['blur', 'change']
  83. },
  84. },
  85. }
  86. },
  87. onLoad(option) {
  88. this.info.id = option.id
  89. this.equipmentName = option.equipmentName
  90. },
  91. onShow() {
  92. this.getMouldList()
  93. },
  94. methods: {
  95. onSubmit() {
  96. this.$refs.form.validate().then(res => {
  97. this.$api.changeModule(this.info).then(res => {
  98. uni.showToast({
  99. title: '修改成功!',
  100. duration: 2000
  101. });
  102. setTimeout(function() {
  103. uni.navigateBack();
  104. }, 2000);
  105. }).catch(err => {})
  106. }).catch(err => {
  107. console.log('表单错误信息:', err);
  108. })
  109. },
  110. timePickerConfirm(e) {
  111. this.info.startTime = this.dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
  112. this.showTimePicker = false
  113. },
  114. getMouldList() {
  115. let params = {
  116. pageSize: '9999',
  117. life: 'false',
  118. }
  119. this.$api.mesMouldList(params).then(res => {
  120. this.mouldActions = res.rows
  121. for (var i = 0; i < this.mouldActions.length; i++) {
  122. this.mouldActions[i].mouldName = this.mouldActions[i].mouldName + '(' + this.mouldActions[
  123. i]
  124. .mouldCode + ')';
  125. }
  126. }).catch(err => {})
  127. },
  128. mouldSelect(e) {
  129. this.info.modulId = e
  130. this.info.productionId = ''
  131. this.getProductionList(e)
  132. },
  133. clearInputValue() {
  134. this.info.productionId = ''
  135. this.productionActions = []
  136. },
  137. getProductionList(id) {
  138. this.$api.getModulProduction(id).then(res => {
  139. this.productionActions = res.data
  140. for (var i = 0; i < this.productionActions.length; i++) {
  141. this.productionActions[i].value = this.productionActions[i].id;
  142. this.productionActions[i].text = this.productionActions[i].materielName + '(' + this
  143. .productionActions[i].materielCode + ')';
  144. }
  145. }).catch(err => {})
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .edit-page {
  152. padding-bottom: 20rpx;
  153. .add-bg {
  154. width: 100%;
  155. height: 330rpx;
  156. }
  157. .form-box {
  158. .form {
  159. background-color: #fff;
  160. margin: 0 24rpx;
  161. padding: 10rpx 24rpx;
  162. border-radius: 12rpx;
  163. }
  164. /deep/.uni-select {
  165. border: none;
  166. padding: 0;
  167. }
  168. }
  169. .submit {
  170. margin: 34rpx;
  171. }
  172. }
  173. </style>