quwangxin 2 years ago
parent
commit
afd2127bea

+ 12 - 1
qiankun_config/store.js

@@ -1,5 +1,5 @@
 import store from '../src/store';
-
+import vue from 'vue';
 export default function (state) {
   if (!state) {
     return;
@@ -19,3 +19,14 @@ export default function (state) {
     store.commit('user/setUserInfo', state.user.info);
   }
 }
+
+export const createMutationObserve = ({ modules = [] }) => {
+  return (mutation, state) => {
+    if (
+      modules?.length &&
+      modules.find((i) => mutation.type.startWidth(i + '/'))
+    ) {
+      vue.$portalStore.commit(mutation.type, mutation.payload);
+    }
+  };
+};

+ 10 - 0
src/components/CreatePlan/ChooseMaterial.vue

@@ -44,6 +44,12 @@
             height="450"
             @row-click="single"
           >
+            <el-table-column
+              label="序号"
+              type="index"
+              width="55"
+              align="center"
+            ></el-table-column>
             <el-table-column
               label="物品编码"
               prop="code"
@@ -113,6 +119,9 @@
       open (categoryId) {
         this.memoId = categoryId;
         this.materialdialog = true;
+        if (this.current?.id) {
+          this._getList();
+        }
       },
       handleNodeClick (info) {
         this.current = info;
@@ -125,6 +134,7 @@
       handleClose () {
         this.materialdialog = false;
         this.selectedRow = {};
+        this.searchKey = '';
       },
 
       handleCurrent (page) {

+ 2 - 0
src/main.js

@@ -60,6 +60,8 @@ export async function bootstrap () {
 export async function mount (props) {
   console.log('[vue] props from main framework', props);
 
+  Vue.prototype.$portalStore = props.store;
+
   initParentStore(props.store);
   props.onGlobalStateChange((state, prev) => {
     // state: 变更后的状态; prev 变更前的状态

+ 3 - 1
src/store/index.js

@@ -9,6 +9,7 @@ import user from './modules/user';
 import selectCache from './modules/selectCache';
 import theme from './modules/theme';
 import createPersistedState from 'vuex-persistedstate';
+import { createMutationObserve } from './store.js';
 
 import { SYSTEM_NAME } from '@/config/setting';
 
@@ -32,6 +33,7 @@ export default new Vuex.Store({
         : `private-vuex-${SYSTEM_NAME}`,
       storage: window.sessionStorage,
       paths: ['user']
-    })
+    }),
+    createMutationObserve({ modules: ['theme', 'user'] })
   ] //会自动保存创建的状态。刷新还在
 });

+ 36 - 0
src/store/store.js

@@ -0,0 +1,36 @@
+// import store from '../src/store';
+import vue from 'vue';
+// export default function (state) {
+//   if (!state) {
+//     return;
+//   }
+//   // 主题
+//   if (state.theme) {
+//     for (const key in state.theme) {
+//       store.commit('theme/SET', { key, value: state.theme[key] });
+//     }
+
+//     store.dispatch('theme/setColor', state.theme.color);
+//     store.dispatch('theme/setWeakMode', state.theme.weakMode);
+//     store.dispatch('theme/setStyleResponsive', state.theme.styleResponsive);
+//   }
+//   //   用户信息
+//   if (state.user?.info) {
+//     store.commit('user/setUserInfo', state.user.info);
+//   }
+// }
+
+export const createMutationObserve = ({ modules = [] }) => {
+  return (store) => {
+    store.subscribe((mutation, state) => {
+      // 每次 mutation 之后调用
+      // mutation 的格式为 { type, payload }
+      if (
+        modules?.length &&
+        modules.find((i) => mutation?.type?.startsWith(i + '/'))
+      ) {
+        vue.$portalStore?.commit(mutation.type, mutation.payload);
+      }
+    });
+  };
+};

+ 37 - 10
src/views/materialPlan/components/plan-edit-dialog.vue

@@ -16,9 +16,17 @@
     >
       <el-row :gutter="32">
         <el-col :span="12">
-          <el-form-item label="选择物料" prop="materialName">
+          <el-form-item
+            label="选择物料"
+            prop="materialName"
+            :key="formData.materialName"
+          >
             <el-input
-              v-model="formData.materialName"
+              placeholder="请选择"
+              :value="
+                formData.materialName &&
+                `${formData.materialName}(${formData.materialCode})`
+              "
               @click.native="chooseMateriel"
             ></el-input>
           </el-form-item>
@@ -48,6 +56,11 @@
             <el-date-picker
               style="width: 100%"
               v-model="formData.deliveryTime"
+              :pickerOptions="{
+                disabledDate: (time) =>
+                  time.getTime() <
+                  new Date(new Date().setHours(0, 0, 0, 0)).getTime()
+              }"
               type="date"
               placeholder="选择日期"
               value-format="yyyy-MM-dd"
@@ -62,16 +75,29 @@
         </el-col> -->
         <el-col :span="12">
           <el-form-item label="生产重量" prop="num">
-            <el-input v-model.number="formData.num">
-              <template slot="suffix">
-                {{ formData.unit }}
-              </template>
-            </el-input>
+            <!-- <el-input v-model.number="formData.num">
+              
+            </el-input> -->
+            <el-row>
+              <el-col :span="21">
+                <el-input-number
+                  placeholder="请输入"
+                  class="w100"
+                  v-model="formData.num"
+                  :controls="false"
+                  :precision="3"
+                  :min="0"
+                ></el-input-number>
+              </el-col>
+              <el-col :span="3" style="text-align: center">
+                {{ formData.unit || 'kg' }}
+              </el-col>
+            </el-row>
           </el-form-item>
         </el-col>
         <el-col :span="12">
           <el-form-item label="计划备注" prop="notes">
-            <el-input v-model="formData.notes"></el-input>
+            <el-input v-model="formData.notes" placeholder="请选择"></el-input>
           </el-form-item>
         </el-col>
       </el-row>
@@ -100,6 +126,7 @@
   import ChooseMaterial from '@/components/CreatePlan/ChooseMaterial.vue';
   import ProductionVersion from '@/components/CreatePlan/ProductionVersion.vue';
   import { save, update } from '@/api/materialPlan/index';
+  import dayjs from 'dayjs';
   export default {
     components: {
       ChooseMaterial,
@@ -140,8 +167,8 @@
           ]
         },
         formData: {
-          deliveryTime: '',
-          num: '',
+          deliveryTime: dayjs(new Date()).format('YYYY-MM-DD'),
+          num: null,
           notes: '',
           categoryId: '',
           unit: '',

+ 31 - 22
src/views/saleOrder/components/order-search.vue

@@ -138,29 +138,31 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 24, md: 24 } : { span: 24 }">
         <el-form-item label-width="0px">
-          <el-button @click="goProduct">转生产计划</el-button>
-          <el-button type="primary" @click="orderRefresh">订单刷新</el-button>
-          <el-button type="success" @click="toCreate">创建订单</el-button>
-          <el-upload
-            class="avatar-uploader"
-            action="#"
-            :show-file-list="false"
-            :http-request="uploadFile"
-            :before-upload="beforeUpload"
-            :on-change="handleChange"
-            ref="uploadFile"
-          >
-            <el-button type="warning">批量导入</el-button>
-          </el-upload>
-          <el-button type="info">
-            <a
-              :href="fileUrl"
-              download="销售订单导入模板.xls"
-              class="button-link"
-              >下载模板</a
+          <div class="btn-wrapper">
+            <el-button @click="goProduct">转生产计划</el-button>
+            <el-button type="primary" @click="orderRefresh">订单刷新</el-button>
+            <el-button type="success" @click="toCreate">创建订单</el-button>
+            <el-upload
+              class="avatar-uploader"
+              action="#"
+              :show-file-list="false"
+              :http-request="uploadFile"
+              :before-upload="beforeUpload"
+              :on-change="handleChange"
+              ref="uploadFile"
             >
-          </el-button>
-          <el-button type="danger" @click="batchDelete">批量删除</el-button>
+              <el-button type="warning">批量导入</el-button>
+            </el-upload>
+            <el-button type="info">
+              <a
+                :href="fileUrl"
+                download="销售订单导入模板.xls"
+                class="button-link"
+                >下载模板</a
+              >
+            </el-button>
+            <el-button type="danger" @click="batchDelete">批量删除</el-button>
+          </div>
         </el-form-item>
       </el-col>
     </el-row>
@@ -373,6 +375,13 @@
     align-items: center;
     justify-content: flex-end;
   }
+
+  .btn-wrapper {
+    display: flex;
+    align-items: center;
+    justify-content: flex-start;
+    flex-wrap: wrap;
+  }
   .avatar-uploader {
     display: inline-block;
     margin: 0 10px;

+ 3 - 1
src/views/saleOrder/index.vue

@@ -264,7 +264,9 @@
 
       /* 刷新表格 */
       reload (where) {
-        this.$refs.table.reload({ page: 1, limit: 10, where });
+        this.$nextTick(() =>
+          this.$refs.table.reload({ page: 1, limit: 10, where })
+        );
       },
 
       openDetails (row) {

+ 2 - 2
vue.config.js

@@ -31,11 +31,11 @@ module.exports = {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
-        target: 'http://192.168.3.35:8080', // kang杨威
+        // target: 'http://192.168.3.35:8080', // kang杨威
         // target: 'http://192.168.3.38:8080', // 陈潇
         // target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
-        // target: 'http://192.168.3.33:8080', // 谢一平
+        target: 'http://192.168.3.33:8080', // 谢一平
         // target: 'http://192.168.3.51:18086', // 测试环境
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域