workOrderReportDialog.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <u-popup
  3. :show="visible"
  4. mode="bottom"
  5. :round="10"
  6. :closeOnClickOverlay="false"
  7. @close="cancel"
  8. class="report-popup"
  9. >
  10. <view class="popup-content">
  11. <view class="popup-header">
  12. <text class="popup-title">报工</text>
  13. <view class="close-btn" @click="cancel">×</view>
  14. </view>
  15. <scroll-view class="popup-body" scroll-y>
  16. <view class="card-a">
  17. <view class="card-section">
  18. <u--form
  19. labelPosition="left"
  20. labelWidth="190rpx"
  21. :model="form"
  22. :rules="rules"
  23. ref="formRef"
  24. >
  25. <u-form-item label="演练实施记录" prop="processRecord" borderBottom required>
  26. <u--textarea
  27. v-model="form.processRecord"
  28. placeholder="请输入"
  29. height="120rpx"
  30. />
  31. </u-form-item>
  32. <u-form-item label="演练时间" prop="drillTime" borderBottom required>
  33. <view class="picker-value" @click="showDateTimePicker">
  34. {{ form.drillTime || '请选择' }}
  35. </view>
  36. <u-icon slot="right" name="arrow-right" />
  37. </u-form-item>
  38. <u-form-item label="附件" prop="processRecordAttachment" borderBottom required>
  39. <fileMain v-model="form.processRecordAttachment" />
  40. </u-form-item>
  41. </u--form>
  42. </view>
  43. </view>
  44. </scroll-view>
  45. <view class="popup-footer">
  46. <u-button type="default" @click="cancel">取消</u-button>
  47. <u-button type="primary" @click="save" :loading="loading">提交</u-button>
  48. </view>
  49. </view>
  50. <u-datetime-picker
  51. :show="showDateTimePopup"
  52. v-model="datetimeValue"
  53. mode="datetime"
  54. @confirm="onDateTimeConfirm"
  55. @cancel="showDateTimePopup = false"
  56. />
  57. <u-toast ref="uToast" />
  58. </u-popup>
  59. </template>
  60. <script>
  61. import fileMain from '@/pages/doc/index.vue';
  62. import { recordProcess } from '@/api/emergencyDrill/workOrder.js';
  63. export default {
  64. components: { fileMain },
  65. data() {
  66. return {
  67. visible: false,
  68. loading: false,
  69. form: {
  70. id: '',
  71. processRecord: '',
  72. processRecordAttachment: [],
  73. drillTime: ''
  74. },
  75. showDateTimePopup: false,
  76. datetimeValue: 0,
  77. rules: {
  78. processRecord: { type: 'string', required: true, message: '请输入演练实施记录', trigger: ['blur', 'change'] },
  79. processRecordAttachment: { type: 'array', required: true, message: '请选择附件', trigger: ['change'] },
  80. drillTime: { type: 'string', required: true, message: '请选择演练时间', trigger: ['change'] }
  81. }
  82. };
  83. },
  84. methods: {
  85. open(row) {
  86. this.visible = true;
  87. this.form = {
  88. id: row.id,
  89. processRecord: '',
  90. processRecordAttachment: [],
  91. drillTime: this.$u.timeFormat(Date.now(), 'yyyy-mm-dd hh:MM:ss')
  92. };
  93. this.$nextTick(() => {
  94. if (this.$refs.formRef) {
  95. this.$refs.formRef.setRules(this.rules);
  96. }
  97. });
  98. },
  99. cancel() {
  100. this.visible = false;
  101. this.form = { id: '', processRecord: '', processRecordAttachment: [], drillTime: '' };
  102. },
  103. showDateTimePicker() {
  104. this.datetimeValue = this.form.drillTime ? new Date(this.form.drillTime).getTime() : Date.now();
  105. this.showDateTimePopup = true;
  106. },
  107. onDateTimeConfirm(e) {
  108. this.showDateTimePopup = false;
  109. this.form.drillTime = this.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
  110. if (this.$refs.formRef) {
  111. this.$refs.formRef.validateField('drillTime');
  112. }
  113. },
  114. async save() {
  115. try {
  116. if (this.$refs.formRef) {
  117. await this.$refs.formRef.validate();
  118. }
  119. if (!this.form.processRecordAttachment || this.form.processRecordAttachment.length === 0) {
  120. this.$refs.uToast.show({ type: 'warning', message: '请选择附件' });
  121. return;
  122. }
  123. this.loading = true;
  124. await recordProcess(this.form);
  125. this.$refs.uToast.show({ type: 'success', message: '报工成功' });
  126. this.cancel();
  127. this.$emit('reload');
  128. } catch (e) {
  129. if (e && e.message) {
  130. this.$refs.uToast.show({ type: 'error', message: e.message });
  131. }
  132. } finally {
  133. this.loading = false;
  134. }
  135. }
  136. }
  137. };
  138. </script>
  139. <style lang="scss" scoped>
  140. .report-popup {
  141. /deep/ .u-popup__content {
  142. border-radius: 32rpx 32rpx 0 0;
  143. overflow: hidden;
  144. }
  145. .popup-content {
  146. height: calc(100vh - 100px);
  147. display: flex;
  148. flex-direction: column;
  149. background: #eff2f7;
  150. }
  151. .popup-header {
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. padding: 30rpx 32rpx;
  156. background: #fff;
  157. border-bottom: 2rpx solid #eef2f6;
  158. flex-shrink: 0;
  159. .popup-title {
  160. font-size: 36rpx;
  161. font-weight: bold;
  162. color: #1f2b3c;
  163. }
  164. .close-btn {
  165. width: 60rpx;
  166. height: 60rpx;
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. font-size: 52rpx;
  171. color: #8e9aae;
  172. line-height: 1;
  173. }
  174. }
  175. .popup-body {
  176. flex: 1;
  177. overflow-y: auto;
  178. padding: 24rpx;
  179. }
  180. .card-a {
  181. background: #ffffff;
  182. border-radius: 48rpx;
  183. box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.05);
  184. overflow: hidden;
  185. }
  186. .card-section {
  187. padding: 30rpx 32rpx;
  188. }
  189. /deep/ .u-form-item {
  190. padding: 12rpx 0;
  191. .u-form-item__body__left__label {
  192. font-size: 26rpx !important;
  193. color: #6c7a91 !important;
  194. }
  195. .u-textarea__field {
  196. font-size: 26rpx !important;
  197. min-height: 100rpx;
  198. }
  199. }
  200. .picker-value {
  201. font-size: 26rpx;
  202. color: #1e2a3a;
  203. text-align: right;
  204. flex: 1;
  205. min-height: 44rpx;
  206. padding: 4rpx 0;
  207. }
  208. .popup-footer {
  209. display: flex;
  210. padding: 16rpx 24rpx;
  211. background: #fff;
  212. border-top: 2rpx solid #eef2f6;
  213. gap: 16rpx;
  214. flex-shrink: 0;
  215. /deep/ .u-button {
  216. flex: 1;
  217. border-radius: 48rpx;
  218. height: 72rpx;
  219. }
  220. }
  221. }
  222. </style>