index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="mould-page">
  3. <navigation title="换模换产"></navigation>
  4. <view class="list-box" v-if="dataList.length>0">
  5. <view class="list-item" v-for="(item, index) in dataList" :key="index">
  6. <view class="item-text">所在设备:{{ item.equipmentName || '-' }}</view>
  7. <view class="item-text">模具名称:{{ item.mouldName || '-' }}</view>
  8. <view class="item-text">模具编码:{{ item.mouldcCode || '-' }}</view>
  9. <view class="item-text">安装时间:{{ timeFormat(item.startTime) }}</view>
  10. <view class="btn-box">
  11. <view class="btn-item" @click="deleteInfo(item.recordId)" v-if="item.modulId">
  12. <view>卸载</view>
  13. </view>
  14. <view class="btn-item" @click="editInfo(item.id, item.equipmentName)">
  15. <view>换模</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <empty v-else text="暂无数据"></empty>
  21. <!-- 输入框(卸载) -->
  22. <u-modal :show="show" title="卸载" :showCancelButton="true" @cancel="cancelStop" @confirm="confirmStop">
  23. <view class="slot-content">
  24. <u--form labelPosition="left" :model="formData" :rules="rules" ref="form" labelWidth="140rpx">
  25. <u-form-item label="卸载时间" prop="endTime" borderBottom @click="showTimePicker = true">
  26. <u--input v-model="formData.endTime" placeholder="请选择卸载时间" border="none" disabled
  27. disabledColor="#ffffff"></u--input>
  28. </u-form-item>
  29. </u--form>
  30. </view>
  31. </u-modal>
  32. <u-datetime-picker :show="showTimePicker" v-model="defaultTime" mode="datetime" @cancel="showTimePicker=false"
  33. @confirm="timePickerConfirm($event)"></u-datetime-picker>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. showTimePicker: false,
  41. defaultTime: Number(new Date()),
  42. dataList: [],
  43. show: false,
  44. formData: {
  45. recordId: '',
  46. endTime: '',
  47. },
  48. rules: {
  49. endTime: {
  50. type: 'string',
  51. required: true,
  52. message: '请选择卸载时间',
  53. trigger: ['blur', 'change']
  54. },
  55. },
  56. }
  57. },
  58. onShow() {
  59. this.getList()
  60. },
  61. methods: {
  62. getList() {
  63. uni.showLoading({
  64. title: '正在加载...'
  65. })
  66. this.$api.listCurrentModule().then(res => {
  67. this.dataList = res.data
  68. uni.hideLoading()
  69. }).catch(err => {})
  70. },
  71. timeFormat(val) {
  72. if (val) {
  73. return this.dayjs(val).format('YYYY-MM-DD HH:mm:ss')
  74. } else {
  75. return '-'
  76. }
  77. },
  78. // 换模
  79. editInfo(id, equipmentName) {
  80. uni.navigateTo({
  81. url: '/subPackages/mould/edit?id=' + id + '&equipmentName=' + equipmentName
  82. });
  83. },
  84. // 卸载
  85. deleteInfo(id) {
  86. this.formData.recordId = id
  87. this.show = true
  88. this.formData.endTime = ''
  89. },
  90. timePickerConfirm(e) {
  91. this.formData.endTime = this.dayjs(e.value).format('YYYY-MM-DD HH:mm:ss')
  92. this.showTimePicker = false
  93. },
  94. confirmStop(val) {
  95. let that = this
  96. this.$refs.form.validate().then(res => {
  97. this.show = false
  98. this.$api.stopModule(this.formData).then(res => {
  99. uni.showToast({
  100. title: '卸载成功!',
  101. duration: 2000
  102. });
  103. setTimeout(function() {
  104. that.getList()
  105. }, 2000);
  106. })
  107. }).catch(errors => {
  108. console.log('校验失败')
  109. })
  110. },
  111. cancelStop() {
  112. this.showTimePicker = false
  113. this.show = false
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .mould-page {
  120. .list-box {
  121. padding: 0 20rpx;
  122. color: $uni-text-color-list;
  123. .list-item {
  124. background-color: $uni-bg-color;
  125. padding: 20rpx;
  126. border-radius: 20rpx;
  127. margin-top: 28rpx;
  128. .item-text {
  129. margin-top: 10rpx;
  130. }
  131. }
  132. .btn-box {
  133. display: flex;
  134. justify-content: flex-end;
  135. margin-top: 10rpx;
  136. .btn-item {
  137. width: 175rpx;
  138. height: 50rpx;
  139. line-height: 50rpx;
  140. text-align: center;
  141. border-radius: 24rpx;
  142. margin-left: 20rpx;
  143. border: 1px solid #43adfd;
  144. color: #43adfd;
  145. }
  146. }
  147. }
  148. }
  149. </style>