| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <u-popup
- :show="visible"
- mode="bottom"
- :round="10"
- :closeOnClickOverlay="false"
- @close="cancel"
- class="report-popup"
- >
- <view class="popup-content">
- <view class="popup-header">
- <text class="popup-title">报工</text>
- <view class="close-btn" @click="cancel">×</view>
- </view>
- <scroll-view class="popup-body" scroll-y>
- <view class="card-a">
- <view class="card-section">
- <u--form
- labelPosition="left"
- labelWidth="190rpx"
- :model="form"
- :rules="rules"
- ref="formRef"
- >
- <u-form-item label="演练实施记录" prop="processRecord" borderBottom required>
- <u--textarea
- v-model="form.processRecord"
- placeholder="请输入"
- height="120rpx"
- />
- </u-form-item>
- <u-form-item label="演练时间" prop="drillTime" borderBottom required>
- <view class="picker-value" @click="showDateTimePicker">
- {{ form.drillTime || '请选择' }}
- </view>
- <u-icon slot="right" name="arrow-right" />
- </u-form-item>
- <u-form-item label="附件" prop="processRecordAttachment" borderBottom required>
- <fileMain v-model="form.processRecordAttachment" />
- </u-form-item>
- </u--form>
- </view>
- </view>
- </scroll-view>
- <view class="popup-footer">
- <u-button type="default" @click="cancel">取消</u-button>
- <u-button type="primary" @click="save" :loading="loading">提交</u-button>
- </view>
- </view>
- <u-datetime-picker
- :show="showDateTimePopup"
- v-model="datetimeValue"
- mode="datetime"
- @confirm="onDateTimeConfirm"
- @cancel="showDateTimePopup = false"
- />
- <u-toast ref="uToast" />
- </u-popup>
- </template>
- <script>
- import fileMain from '@/pages/doc/index.vue';
- import { recordProcess } from '@/api/emergencyDrill/workOrder.js';
- export default {
- components: { fileMain },
- data() {
- return {
- visible: false,
- loading: false,
- form: {
- id: '',
- processRecord: '',
- processRecordAttachment: [],
- drillTime: ''
- },
- showDateTimePopup: false,
- datetimeValue: 0,
- rules: {
- processRecord: { type: 'string', required: true, message: '请输入演练实施记录', trigger: ['blur', 'change'] },
- processRecordAttachment: { type: 'array', required: true, message: '请选择附件', trigger: ['change'] },
- drillTime: { type: 'string', required: true, message: '请选择演练时间', trigger: ['change'] }
- }
- };
- },
- methods: {
- open(row) {
- this.visible = true;
- this.form = {
- id: row.id,
- processRecord: '',
- processRecordAttachment: [],
- drillTime: this.$u.timeFormat(Date.now(), 'yyyy-mm-dd hh:MM:ss')
- };
- this.$nextTick(() => {
- if (this.$refs.formRef) {
- this.$refs.formRef.setRules(this.rules);
- }
- });
- },
- cancel() {
- this.visible = false;
- this.form = { id: '', processRecord: '', processRecordAttachment: [], drillTime: '' };
- },
- showDateTimePicker() {
- this.datetimeValue = this.form.drillTime ? new Date(this.form.drillTime).getTime() : Date.now();
- this.showDateTimePopup = true;
- },
- onDateTimeConfirm(e) {
- this.showDateTimePopup = false;
- this.form.drillTime = this.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss');
- if (this.$refs.formRef) {
- this.$refs.formRef.validateField('drillTime');
- }
- },
- async save() {
- try {
- if (this.$refs.formRef) {
- await this.$refs.formRef.validate();
- }
- if (!this.form.processRecordAttachment || this.form.processRecordAttachment.length === 0) {
- this.$refs.uToast.show({ type: 'warning', message: '请选择附件' });
- return;
- }
- this.loading = true;
- await recordProcess(this.form);
- this.$refs.uToast.show({ type: 'success', message: '报工成功' });
- this.cancel();
- this.$emit('reload');
- } catch (e) {
- if (e && e.message) {
- this.$refs.uToast.show({ type: 'error', message: e.message });
- }
- } finally {
- this.loading = false;
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .report-popup {
- /deep/ .u-popup__content {
- border-radius: 32rpx 32rpx 0 0;
- overflow: hidden;
- }
- .popup-content {
- height: calc(100vh - 100px);
- display: flex;
- flex-direction: column;
- background: #eff2f7;
- }
- .popup-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 30rpx 32rpx;
- background: #fff;
- border-bottom: 2rpx solid #eef2f6;
- flex-shrink: 0;
- .popup-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #1f2b3c;
- }
- .close-btn {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 52rpx;
- color: #8e9aae;
- line-height: 1;
- }
- }
- .popup-body {
- flex: 1;
- overflow-y: auto;
- padding: 24rpx;
- }
- .card-a {
- background: #ffffff;
- border-radius: 48rpx;
- box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.05);
- overflow: hidden;
- }
- .card-section {
- padding: 30rpx 32rpx;
- }
- /deep/ .u-form-item {
- padding: 12rpx 0;
- .u-form-item__body__left__label {
- font-size: 26rpx !important;
- color: #6c7a91 !important;
- }
- .u-textarea__field {
- font-size: 26rpx !important;
- min-height: 100rpx;
- }
- }
- .picker-value {
- font-size: 26rpx;
- color: #1e2a3a;
- text-align: right;
- flex: 1;
- min-height: 44rpx;
- padding: 4rpx 0;
- }
- .popup-footer {
- display: flex;
- padding: 16rpx 24rpx;
- background: #fff;
- border-top: 2rpx solid #eef2f6;
- gap: 16rpx;
- flex-shrink: 0;
- /deep/ .u-button {
- flex: 1;
- border-radius: 48rpx;
- height: 72rpx;
- }
- }
- }
- </style>
|