| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <template>
- <view class="mx3" style="padding-bottom: 100rpx">
- <u-toast ref="uToast" />
- <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
- <view
- class="p3 bg-color-white"
- style="margin-top: -50rpx; border-radius: 20rpx"
- >
- <u-form :model="form" ref="uForm" >
- <view class="main-color-text f-size-32 f-weight-6 mt-2">调拨信息</view>
- <u-form-item label="调出仓库" :label-width="150">
- <u-input v-model="form.storeName" disabled />
- </u-form-item>
- <u-form-item label="调入仓库" required prop="running" :label-width="150">
- <u-input
- v-model="form.inStoreName"
- disabled
- @click="handleSelect"
- placeholder="请选择仓库"
- type="select"
- />
- </u-form-item>
- <u-form-item label="备件名称" :label-width="150">
- <u-input v-model="form.spareName" disabled />
- </u-form-item>
- <u-form-item label="备件编号" :label-width="150">
- <u-input v-model="form.spareNo" disabled />
- </u-form-item>
- <u-form-item label="库存价格" prop="price" required :label-width="150">
- <u-input v-model="form.price"/>
- </u-form-item>
- <u-form-item label="库存数量" prop="num" required :label-width="150">
- <u-input v-model="form.storeNum" :cursor-spacing="cursorSpacing"/>
- </u-form-item>
- <u-form-item label="调拨数量" prop="storeNum" required :label-width="150">
- <u-input v-model="form.num" :cursor-spacing="cursorSpacing"/>
- </u-form-item>
- </u-form>
- <!-- <button class="main-color-bg text-color-white" @tap='handleSubmit'>提交</button> -->
- <view class="p-fixed d-flex j-around a-center footer">
- <view
- class="main-color-bg text-color-white common"
- @tap="handleSubmit"
- >提交</view
- >
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- form: {
- price: '',
- spareName: '',
- spareId: '',
- spareNo: '',
- storeId: '',
- storeName: '',
- inStoreName: '',
- inStoreId: '',
- num: ''
- },
- data: [],
- badState: false,
- badList: [],
- runningState: false, // 设备选择
- runningList: [],
- haltState: false, // 是否停机
- haltList: [],
- repairState: false, // 报修来源
- repairList: [],
- levelState: false,
- levelList: [],
- imagesList: [],
- action: this.$BaseTool.UserUtil.getUploadUrlIgnores(),
- // action: 'http://39.103.133.141:8000/mock/7/upms/files/upload',
- /*header: {
- Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
- },*/
- fileList: [],
- sourceMap: {},
- levelMap: {},
- statusMap: {},
- needStopMap: {},
- haltDefaultValue: [0],
- rules: {
- num: [
- {
- required: true,
- message: '请填写出库数量',
- trigger: ['blur', 'change']
- }
- ],
- price: [
- {
- required: true,
- message: '请填写库存价格',
- trigger: ['blur', 'change']
- }
- ]
- },
- // #ifdef MP-WEIXIN
- cursorSpacing: 50,
- // #endif
- // #ifndef MP-WEIXIN
- cursorSpacing: 0,
- // #endif
- backId: '',
- backName: '',
- aShow: false,
- address: '',
- sbId: null,
- aList: [
- ]
- };
- },
- onShow() {
- const pages = getCurrentPages();
- const currPage = pages[pages.length - 1];
- this.backId = currPage.backId;
- this.backName = currPage.backName;
- this.form.inStoreName = this.backName;
- this.form.inStoreId = this.backId;
- console.log('this.form.inStoreName:' + this.form.inStoreName)
- },
- onLoad(options) {
- this.form.spareId = options.spareId;
- this.form.spareName = options.spareName;
- this.form.spareNo = options.spareNo;
- this.form.storeNum = options.storeNum;
- this.form.storeId = options.storeId;
- this.form.storeName = options.storeName;
- this.form.price = options.price;
- this.sourceMap = this.$DictCache.getLabelByValueMapByType(
- this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE
- );
- for (const key in this.sourceMap) {
- this.repairList.push({
- label: this.sourceMap[key],
- value: key
- });
- }
- this.form.repair = this.repairList[0].label;
- this.form.source = this.repairList[0].value;
- this.levelMap = this.$DictCache.getLabelByValueMapByType(
- this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL
- );
- for (const key in this.levelMap) {
- this.levelList.push({
- label: this.levelMap[key],
- value: key
- });
- }
- this.form.level = this.levelList[0].label;
- this.form.levelValue = this.levelList[0].value;
- this.statusMap = this.$DictCache.getLabelByValueMapByType(
- this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS
- );
- this.needStopMap = this.$DictCache.getLabelByValueMapByType(
- this.$DictCache.TYPE.YES_NO
- );
- for (const key in this.needStopMap) {
- this.haltList.push({
- label: this.needStopMap[key],
- value: key
- });
- }
- this.form.halt = this.haltList[this.haltDefaultValue].label;
- this.form.needStop = this.haltList[this.haltDefaultValue].value;
- this.getType()
- // 获取设备数据
- // this.initSb();
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- },
- methods: {
- //
- confirm(e) {
- console.log(e);
- this.address = ''
- for (let i = 0; i < e.length; i++) {
- this.address += e[i].label
- }
- },
- badSubmit(data) {
- this.form.badType = data[0].label;
- this.form.repairErrorTypeId = data[0].value;
- },
- getType() {
- /* this.$Http
- .fetchErrorTypeTree({
- id: this.detailId
- })
- .then((res) => {
- console.log(res.data);
- const temp = []
- res.data.forEach(item => {
- temp.push({
- label: item.title,
- value: item.id
- })
- })
- this.badList = temp
- console.log(this.badList);
- }) */
- },
- handleSelect() {
- uni.navigateTo({
- url: '/pages/search/search-store'
- })
- },
- // 选择仓库
- runningSubmit(data) {
- console.log(data);
- this.form.storeId = data.value;
- this.$Http
- .fetchStore({
- id: data.value
- })
- .then((res) => {
- this.form.storeName = res.data.name;
- this.form.running = res.data.name;
- });
- this.form.running = data.label;
- },
- handleSubmit() {
- if(this.form.storeNum<=0){
- uni.showToast({ icon: 'none', title: '库存数量为0,无法调拨!', duration: 2000 });
- return
- }
- if(this.form.num<=0){
- uni.showToast({ icon: 'none', title: '出库数量必须大于0!', duration: 2000 });
- return
- }
- if((this.form.storeNum - this.form.num) <= 0){
- uni.showToast({ icon: 'none', title: '调拨数量不得大于库存数量!', duration: 2000 });
- return
- }
- if(this.form.storeId == this.form.inStoreId){
- uni.showToast({ icon: 'none', title: '请选择不同的仓库!', duration: 2000 });
- return
- }
- const params = {
- storeId: this.form.storeId,
- inStoreId: this.form.inStoreId,
- detailList:[{
- price: this.form.price,
- spareId: this.form.spareId,
- storeId: this.form.storeId,
- num: this.form.num
- }]
- };
- // this.form.photo = a.join(',');
- var that = this;
- this.$refs.uForm.validate((valid) => {
- if (valid) {
- this.$Http.addTransferStoreForm(params).then((res) => {
- uni.showToast({ icon: 'none', title: '已提交!', duration: 2000 });
- setTimeout(function () {
- uni.navigateTo({
- url: '/pages/spare/spare-store?detailId=' + that.form.spareId
- });
- }, 2000)
- });
- }
- });
- }
- }
- };
- </script>
- <style lang="less">
- .footer {
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #fff;
- z-index: 10000;
- border-top: 1rpx solid #f4f4f4;
- height: 100rpx;
- .common {
- padding: 15rpx 200rpx;
- border-radius: 30rpx;
- background-color: #0082ff;
- color: #fff;
- }
- }
- </style>
|