| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <view class="mx3">
- <view class="main-color-bg main-bg-future"></view>
- <view class="p3 bg-color-white form-view">
- <u-form :model="form" ref="uForm" >
- <u-form-item
- label="作业名称"
- prop="projectQuantityId"
- :label-width="220">
- <my-select
- :list="projectQuantityList"
- :value-name="'id'"
- :label-name="'name'"
- v-model="form.projectQuantityId"
- @selected="changeProjectQuantity"
- placeholder="请选择"
- />
- </u-form-item>
- <u-form-item
- label="作业位置"
- :label-width="220">
- <view class="d-flex">
- <u-input
- style="width: 100rpx;"
- v-model="form.projectQuantityStart"
- type="number"
- @blur="numBlur($event, 'projectQuantityStart')"
- placeholder="起始值" />
- <text class="px3">至</text>
- <u-input
- style="width: 100rpx;"
- v-model="form.projectQuantityEnd"
- type="number"
- @blur="numBlur($event, 'projectQuantityEnd')"
- placeholder="结束值" />
- <u-input :disabled="true" style="width: 70rpx;" v-model="projectQuantitySiteUnit"/>
- </view>
- </u-form-item>
- </u-form>
- </view>
- <view class="mt-3">
- <u-button @click="submit" type="primary" shape="circle">提交</u-button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- form: {
- projectQuantityId: '',
- projectQuantityStart: 0,
- projectQuantityEnd: 0
- },
- projectQuantitySiteUnit: '无',
- projectQuantityList: [],
- projectQuantityUnitMap: {},
- rules: {
- projectQuantityId: [
- {
- required: true,
- message: '请选择作业名称',
- trigger: ['change']
- }
- ],
- projectQuantityStart: [
- {
- required: true,
- message: '请输入起始值',
- trigger: ['blur', 'change']
- }
- ],
- projectQuantityEnd: [
- {
- required: true,
- message: '请输入结束值',
- trigger: ['blur', 'change']
- }
- ]
- },
- id: '' // 列表 id
- };
- },
- onShow() {
- // 获取设备与仓库
- this.initData();
- },
- onLoad(options) {
- this.projectQuantityUnitMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.FILL_PROJECT_QUANTITY_UNIT)
- },
- // watch: {
- // 'form.projectQuantityStart': {
- // handler(newVal, oldVal) {
- // console.log(newVal, oldVal)
- // if (!newVal && newVal !== 0) {
- // this.form.projectQuantityStart = 0
- // }
- // },
- // deep: true
- // }
- // },
- methods: {
- initData() {
- this.$Http.queryFillProjectQuantityDeptProject({ filter: 1 }).then(res => {
- this.projectQuantityList = res.data
- })
- },
- numBlur(e, type) {
- // console.log(!e, type === 'projectQuantityStart')
- // if (!e) {
- // if (type === 'projectQuantityStart') {
- // this.$set(this.form, 'projectQuantityStart', 0);
- // } else {
- // this.form.projectQuantityEnd = 0
- // }
- // }
- },
- changeProjectQuantity(value, data) {
- console.log(value, data)
- this.projectQuantitySiteUnit = this.projectQuantityUnitMap[data.siteUnit]
- },
- submit() {
- this.$refs.uForm.validate(valid => {
- const sbRunList = uni.getStorageSync('sb-run-list');
- if (valid) {
- if (!this.form.projectQuantityStart && this.form.projectQuantityStart !== 0) {
- uni.showToast({ title: '起始值不能为空', icon: 'none' })
- return
- }
- if (!this.form.projectQuantityEnd && this.form.projectQuantityEnd !== 0) {
- uni.showToast({ title: '结束值不能为空', icon: 'none' })
- return
- }
- this.$Http.batchUpdateProject({ ...this.form, targetIds: sbRunList }).then(res => {
- uni.removeStorageSync('sb-run-list')
- uni.redirectTo({
- url: '/pages/running/running'
- });
- }).catch(() => {
- })
- }
- });
- }
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- }
- };
- </script>
- <style lang="less">
- page {
- background-color: #f4f4f4;
- }
- </style>
|