Explorar o código

物料组静态页面提交

LAPTOP-16IUEB3P\Lenovo %!s(int64=3) %!d(string=hai) anos
pai
achega
bb23903446

+ 181 - 0
src/views/material/list/components/CategoryDialog.vue

@@ -0,0 +1,181 @@
+<template>
+  <el-dialog
+    title="选择分类"
+    :visible.sync="categoryVisible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="60%"
+  >
+    <div>
+      <el-row>
+		<el-col :span="24" class="topsearch">
+			<el-form label-width="100px">
+			  <el-row>
+          <el-col :span="8">
+             <el-form-item label="类型编码:">
+               <el-input
+                 clearable
+                 placeholder="请输入"
+                 v-model.trim="search.code"
+               ></el-input>
+             </el-form-item>
+          </el-col>
+          <el-col :span="8">
+             <el-form-item label="类型名称:">
+               <el-input
+                 clearable
+                 v-model="search.name"
+                 placeholder="请输入"
+               ></el-input>
+             </el-form-item>
+          </el-col>
+          <el-col :span="6">
+             <el-form-item  label-width="20px">
+                <el-button type="primary" @click="getList">搜索</el-button>
+                <el-button @click="reset">重置</el-button>
+             </el-form-item>
+          </el-col>
+			  </el-row>
+			</el-form>
+		</el-col>
+        <el-col :span="24" class="table_col">
+          <el-table
+            :data="tableData"
+            height="450"
+            highlight-current-row
+            @row-click="single"
+          >
+            <el-table-column label="类型编码" prop="code" width="200"></el-table-column>
+            <el-table-column label="类型名称" prop="name"></el-table-column>
+            <el-table-column label="描述" prop="remark"></el-table-column>
+            <el-table-column label="选择" align="center">
+               <template slot-scope="scope">
+            	 <el-radio class="radio" v-model="radio" :label="scope.row.id"><i></i></el-radio>
+               </template>
+            </el-table-column>
+          </el-table>
+         <div class="pagination">
+            <el-pagination
+              background
+              layout="total, sizes, prev, pager, next, jumper"
+              :total="total"
+              :page-sizes="[10, 20, 50, 100]"
+              :page-size="pagination.size"
+              :current-page.sync="pagination.pageNum"
+              @current-change="handleCurrent"
+              @size-change="handleSize"
+            >
+            </el-pagination>
+          </div>
+        </el-col>
+      </el-row>
+    </div>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { getSubPage } from '@/api/classifyManage';
+export default {
+  data () {
+    return {
+      categoryVisible: false,
+      tableData: [],
+      search:{},
+      pagination: {
+        pageNum: 1,
+        size: 10,
+      },
+      total: 0,
+      radio: '',
+      current:null
+    }
+  },
+
+  watch: {
+
+  },
+  methods: {
+    open(){
+      this.categoryVisible = true
+      this.getList()
+    },
+
+    // 单击获取id
+    single (row) {
+        this.current = row
+        this.radio = row.id
+    },
+
+    handleClose () {
+      this.categoryVisible = false
+      this.current = null
+      this.radio = ''
+    },
+    reset(){
+      this.search={}
+      this.getList()
+    },
+    handleCurrent (page) {
+      this.pagination.pageNum = page
+      this.getList()
+    },
+    handleSize (size) {
+      this.pagination.pageNum = 1
+      this.pagination.size = size
+      this.getList()
+    },
+    getList(){
+      let params = {
+        ...this.search,
+        ...this.pagination,
+        parentId: 0
+      }
+      getSubPage(params).then(res=>{
+         this.tableData = res.list
+         this.total = res.count
+      })
+    },
+      selected(){
+         if(!this.current){
+           return this.$message.warning('请选择分类')
+         }
+         this.$emit('changeCategory',this.current)
+         this.handleClose()
+      },
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.tree_col {
+  border: 1px solid #eee;
+  padding: 10px 0;
+  box-sizing: border-box;
+  height: 500px;
+  overflow: auto;
+}
+.table_col {
+  padding-left: 10px;
+  ::v-deep .el-table th.el-table__cell {
+    background: #f2f2f2;
+  }
+}
+.pagination {
+  text-align: right;
+  padding: 10px 0;
+}
+.btns {
+  text-align: center;
+  padding: 10px 0;
+}
+.topsearch{
+	margin-bottom:15px;
+}
+</style>

+ 165 - 0
src/views/material/list/components/list-edit.vue

@@ -0,0 +1,165 @@
+<!-- 物料组编辑弹窗 -->
+<template>
+  <ele-modal
+    width="720px"
+    :visible="visible"
+    :append-to-body="true"
+    :close-on-click-modal="true"
+    custom-class="ele-dialog-form"
+    :title="isUpdate ? '修改物料组' : '添加物料组'"
+    @update:visible="updateVisible"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="物料组编码:" prop="code">
+             <el-input
+               clearable
+               :maxlength="20"
+               :disabled="isUpdate"
+               v-model="form.code"
+               placeholder="请输入物料组名称"
+             />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="物料组名称:" prop="name">
+            <el-input
+              clearable
+              :maxlength="20"
+              v-model="form.name"
+              placeholder="请输入物料组名称"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="分类树" prop="categoryLevelName">
+            <el-input
+              v-model="form.categoryLevelName"
+               @click.native="chooseCategory"
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template v-slot:footer>
+      <el-button @click="updateVisible(false)">取消</el-button>
+      <el-button type="primary" :loading="loading" @click="save">
+        保存
+      </el-button>
+    </template>
+
+    <CategoryDialog ref="categoryRefs" @changeCategory="changeCategory"></CategoryDialog>
+  </ele-modal>
+</template>
+
+<script>
+  import CategoryDialog from './CategoryDialog.vue'
+  import { addUsers, putUsers } from '@/api/system/user';
+
+  export default {
+    components: {
+      CategoryDialog
+    },
+    props: {
+      // 弹窗是否打开
+      visible: Boolean,
+      // 修改回显的数据
+      data: Object
+    },
+    data() {
+      const defaultForm = {
+        id: null,
+        name: '',
+        code: '',
+        categoryLevelName: ''
+      };
+      return {
+        defaultForm,
+        // 表单数据
+        form: { ...defaultForm },
+        // 表单验证规则
+        rules: {
+          code: [
+            { required: true, message: '请输入物料组编码', trigger: 'blur' }
+          ],
+          name: [
+            { required: true, message: '请输入物料组名称', trigger: 'blur' }
+          ],
+          categoryLevelName: [
+            { required: true, message: '请选择所属分类', trigger: 'change' }
+          ]
+        },
+        // 提交状态
+        loading: false,
+        // 是否是修改
+        isUpdate: false
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    methods: {
+      chooseCategory(){
+           this.$refs.categoryRefs.open()
+      },
+      changeCategory(row){
+        console.log('rrr',row)
+         this.$set(this.form,'categoryLevelName',row.name)
+         this.$set(this.form,'categoryLevelId',row.id)
+      },
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+          this.loading = true;
+          if (!this.isUpdate) {
+            delete this.form.id;
+          }
+          const data = {
+            ...this.form
+          };
+          const saveOrUpdate = this.isUpdate ? putUsers : addUsers;
+          saveOrUpdate(data)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.updateVisible(false);
+              this.$emit('done');
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+      /* 更新visible */
+      updateVisible(value) {
+        this.$emit('update:visible', value);
+      }
+    },
+    watch: {
+      visible(visible) {
+        if (visible) {
+          if (this.data) {
+            this.$util.assignObject(this.form, {
+              ...this.data,
+              // roleId: this.data.roleList.map((d) => d.id),
+              // loginPwd: ''
+            });
+            this.isUpdate = true;
+          } else {
+            this.isUpdate = false;
+          }
+        } else {
+          this.$refs.form.clearValidate();
+          this.form = { ...this.defaultForm };
+        }
+      }
+    }
+  };
+</script>

+ 24 - 126
src/views/material/list/index.vue

@@ -23,15 +23,6 @@
           >
             新建
           </el-button>
-          <el-button
-            size="small"
-            type="danger"
-            icon="el-icon-delete"
-            class="ele-btn-icon"
-            @click="removeBatch"
-          >
-            删除
-          </el-button>
         </template>
 
         <template v-slot:roleList="{ row }">
@@ -65,19 +56,11 @@
             icon="el-icon-edit"
             @click="openEdit(row)"
           >
-            修改
-          </el-link>
-          <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-key"
-            @click="resetPsw(row)"
-          >
-            重置密码
+            编辑
           </el-link>
           <el-popconfirm
             class="ele-action"
-            title="确定要删除此用户吗?"
+            title="确定要删除此物料组吗?"
             @confirm="remove(row)"
           >
             <template v-slot:reference>
@@ -90,24 +73,27 @@
       </ele-pro-table>
     </el-card>
     <!-- 编辑弹窗 -->
+    <list-edit
+      :visible.sync="showEdit"
+      :data="current"
+      @done="reload"
+      ref="listEdit"
+    />
   </div>
 </template>
 
 <script>
+  import { pageUsers } from '@/api/system/user';
+  import ListEdit from './components/list-edit.vue';
   export default {
-    name: 'SystemUser',
-
-    data() {
+    name: 'MaterialList',
+    components: {
+      ListEdit
+    },
+    data () {
       return {
         // 表格列配置
         columns: [
-          {
-            columnKey: 'selection',
-            type: 'selection',
-            width: 45,
-            align: 'center',
-            fixed: 'left'
-          },
           {
             columnKey: 'index',
             type: 'index',
@@ -119,21 +105,21 @@
           },
           {
             prop: 'loginName',
-            label: '用户账号',
+            label: '物料组名称',
             // sortable: 'custom',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
             columnKey: 'roleList',
-            label: '角色',
+            label: '物料组编码',
             showOverflowTooltip: true,
             minWidth: 110,
             slot: 'roleList'
           },
           {
             prop: 'createTime',
-            label: '创建时间',
+            label: '关联分类树',
             // sortable: 'custom',
             showOverflowTooltip: true,
             minWidth: 110,
@@ -141,16 +127,6 @@
               return this.$util.toDateString(cellValue);
             }
           },
-          {
-            prop: 'enable',
-            label: '状态',
-            align: 'center',
-            // sortable: 'custom',
-            width: 80,
-            resizable: false,
-            slot: 'enable',
-            showOverflowTooltip: true
-          },
           {
             columnKey: 'action',
             label: '操作',
@@ -166,47 +142,26 @@
         // 当前编辑数据
         current: null,
         // 是否显示编辑弹窗
-        showEdit: false,
-        // 是否显示导入弹窗
-        showImport: false
+        showEdit: false
       };
     },
     methods: {
       /* 表格数据源 */
-      datasource({ page, limit, where, order }) {
+      datasource ({ page, limit, where, order }) {
         return pageUsers({ ...where, ...order, pageNum: page, size: limit });
       },
-      async changeEnable(row) {
-        let params = { ...row };
-        params.roleId = row.roleList.map((d) => d.id);
-        delete params.roleList;
-        const res = await putUsers(params);
-        if (res.code == 0) {
-          this.$message({
-            type: 'success',
-            message: '修改成功',
-            customClass: 'ele-message-border'
-          });
-          this.reload();
-        }
-      },
       /* 刷新表格 */
-      reload(where) {
+      reload (where) {
         this.$refs.table.reload({ page: 1, where: where });
       },
       /* 打开编辑弹窗 */
-      openEdit(row) {
+      openEdit (row) {
         this.current = row;
         this.showEdit = true;
-        this.$refs.userEdit.$refs.form &&
-          this.$refs.userEdit.$refs.form.clearValidate();
-      },
-      /* 打开导入弹窗 */
-      openImport() {
-        this.showImport = true;
+        this.$refs.listEdit.$refs.form &&this.$refs.listEdit.$refs.form.clearValidate();
       },
       /* 删除 */
-      remove(row) {
+      remove (row) {
         const loading = this.$loading({ lock: true });
         deleteUsers([row.id])
           .then((msg) => {
@@ -218,63 +173,6 @@
             loading.close();
             // this.$message.error(e.message);
           });
-      },
-      /* 批量删除 */
-      removeBatch() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
-        }
-        this.$confirm('确定要删除选中的用户吗?', '提示', {
-          type: 'warning'
-        })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            deleteUsers(this.selection.map((d) => d.id))
-              .then((msg) => {
-                loading.close();
-                this.$message.success(msg);
-                this.reload();
-              })
-              .catch((e) => {
-                loading.close();
-                // this.$message.error(e.message);
-              });
-          })
-          .catch(() => {});
-      },
-      /* 重置用户密码 */
-      resetPsw(row) {
-        this.$confirm('确定要重置此用户的密码为"123456"吗?', '提示', {
-          type: 'warning'
-        })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            resetPassword(row.id)
-              .then((msg) => {
-                loading.close();
-                this.$message.success(msg);
-              })
-              .catch((e) => {
-                loading.close();
-                // this.$message.error(e.message);
-              });
-          })
-          .catch(() => {});
-      },
-      /* 更改状态 */
-      editStatus(row) {
-        const loading = this.$loading({ lock: true });
-        updateUserStatus(row.userId, row.status)
-          .then((msg) => {
-            loading.close();
-            this.$message.success(msg);
-          })
-          .catch((e) => {
-            loading.close();
-            row.status = !row.status ? 1 : 0;
-            // this.$message.error(e.message);
-          });
       }
     }
   };

+ 4 - 4
vue.config.js

@@ -3,7 +3,7 @@ const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme');
 const path = require('path');
 const { name } = require('./package.json');
 
-function resolve(dir) {
+function resolve (dir) {
   return path.join(__dirname, dir);
 }
 
@@ -33,9 +33,9 @@ module.exports = {
       '/api': {
         // target: 'http://192.168.3.51:18086', // 测试
         // target: 'http://192.168.3.35:8080', // kang杨威
-        target: 'http://192.168.3.25: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.64:8080', // 粟勋
         // target: 'http://192.168.3.34:8080', // 刘毅勋
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
@@ -48,7 +48,7 @@ module.exports = {
       'Access-Control-Allow-Origin': '*'
     }
   },
-  chainWebpack(config) {
+  chainWebpack (config) {
     config.plugins.delete('prefetch');
     // set svg-sprite-loader
     // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();