Browse Source

添加货品管理、商城管理(未完成)

asd123a20 3 years ago
parent
commit
04d9b8715f
44 changed files with 26207 additions and 29 deletions
  1. 12 0
      admin-frame/lib/apps.js
  2. 3 0
      admin-goods/.browserslistrc
  3. 5 0
      admin-goods/.editorconfig
  4. 2 0
      admin-goods/.env
  5. 1 0
      admin-goods/.eslintignore
  6. 23 0
      admin-goods/.eslintrc.js
  7. 23 0
      admin-goods/.gitignore
  8. 24 0
      admin-goods/README.md
  9. 5 0
      admin-goods/babel.config.js
  10. 12586 0
      admin-goods/package-lock.json
  11. 35 0
      admin-goods/package.json
  12. BIN
      admin-goods/public/favicon.ico
  13. 17 0
      admin-goods/public/index.html
  14. 24 0
      admin-goods/src/App.vue
  15. BIN
      admin-goods/src/assets/logo.png
  16. 48 0
      admin-goods/src/main.js
  17. 3 0
      admin-goods/src/public-path.js
  18. 10 0
      admin-goods/src/router/index.js
  19. 55 0
      admin-goods/src/store/index.js
  20. 196 0
      admin-goods/src/views/Home.vue
  21. 33 0
      admin-goods/vue.config.js
  22. 0 17
      admin-journal-catalogue/src/views/home.vue
  23. 1 12
      admin-journal-intact/src/views/home.vue
  24. 3 0
      admin-market/.browserslistrc
  25. 5 0
      admin-market/.editorconfig
  26. 2 0
      admin-market/.env
  27. 1 0
      admin-market/.eslintignore
  28. 23 0
      admin-market/.eslintrc.js
  29. 23 0
      admin-market/.gitignore
  30. 24 0
      admin-market/README.md
  31. 5 0
      admin-market/babel.config.js
  32. 12586 0
      admin-market/package-lock.json
  33. 35 0
      admin-market/package.json
  34. BIN
      admin-market/public/favicon.ico
  35. 17 0
      admin-market/public/index.html
  36. 24 0
      admin-market/src/App.vue
  37. BIN
      admin-market/src/assets/logo.png
  38. 48 0
      admin-market/src/main.js
  39. 3 0
      admin-market/src/public-path.js
  40. 10 0
      admin-market/src/router/index.js
  41. 55 0
      admin-market/src/store/index.js
  42. 198 0
      admin-market/src/views/Home.vue
  43. 33 0
      admin-market/vue.config.js
  44. 6 0
      xms.code-workspace

+ 12 - 0
admin-frame/lib/apps.js

@@ -86,5 +86,17 @@ export default [
     entry: config.dev ? '//localhost:3013/admin-journal-catalogue/' : 'admin-journal-catalogue',
     container: config.tabs ? '#catalogue' : '#content',
     activeRule: '/admin/catalogue'
+  },
+  {
+    name: 'admin-goods',
+    entry: config.dev ? '//localhost:3014/admin-goods/' : 'admin-goods',
+    container: config.tabs ? '#goods' : '#content',
+    activeRule: '/admin/goods'
+  },
+  {
+    name: 'admin-market',
+    entry: config.dev ? '//localhost:3015/admin-market/' : 'admin-market',
+    container: config.tabs ? '#market' : '#content',
+    activeRule: '/admin/market'
   }
 ];

+ 3 - 0
admin-goods/.browserslistrc

@@ -0,0 +1,3 @@
+> 1%
+last 2 versions
+not dead

+ 5 - 0
admin-goods/.editorconfig

@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 2 - 0
admin-goods/.env

@@ -0,0 +1,2 @@
+# 窗口使用弹出还是抽屉 (dialog And drawer)
+VUE_APP_WINDOW=dialog

+ 1 - 0
admin-goods/.eslintignore

@@ -0,0 +1 @@
+public-path.js

+ 23 - 0
admin-goods/.eslintrc.js

@@ -0,0 +1,23 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/essential',
+    '@vue/standard'
+  ],
+  parserOptions: {
+    parser: 'babel-eslint'
+  },
+  rules: {
+    'no-console': 0,
+    'no-debugger': 0,
+    'comma-dangle': [2, 'never'],
+    'no-extra-parens': 2,
+    'no-extra-semi': 2,
+    semi: [2, 'always'],
+    'space-before-function-paren': [0, 'always'],
+    eqeqeq: 0
+  }
+};

+ 23 - 0
admin-goods/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 24 - 0
admin-goods/README.md

@@ -0,0 +1,24 @@
+# admin-code
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Lints and fixes files
+```
+npm run lint
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
admin-goods/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+};

File diff suppressed because it is too large
+ 12586 - 0
admin-goods/package-lock.json


+ 35 - 0
admin-goods/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "admin-goods",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "core-js": "^3.6.5",
+    "element-ui": "^2.15.6",
+    "vue": "^2.6.11",
+    "vue-router": "^3.2.0",
+    "vuex": "^3.4.0"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.5.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/cli-plugin-router": "~4.5.0",
+    "@vue/cli-plugin-vuex": "~4.5.0",
+    "@vue/cli-service": "~4.5.0",
+    "@vue/eslint-config-standard": "^5.1.2",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-import": "^2.20.2",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-promise": "^4.2.1",
+    "eslint-plugin-standard": "^4.0.0",
+    "eslint-plugin-vue": "^6.2.2",
+    "sass": "^1.45.1",
+    "sass-loader": "^10.0.0",
+    "vue-template-compiler": "^2.6.11"
+  }
+}

BIN
admin-goods/public/favicon.ico


+ 17 - 0
admin-goods/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 24 - 0
admin-goods/src/App.vue

@@ -0,0 +1,24 @@
+<template>
+  <div id="app">
+    <router-view></router-view>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  computed: {},
+  data() {
+    return {};
+  },
+  mounted() {},
+  methods: {}
+};
+</script>
+
+<style lang="scss" scoped>
+#app {
+  width: 100%;
+  height: 100%;
+}
+</style>

BIN
admin-goods/src/assets/logo.png


+ 48 - 0
admin-goods/src/main.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import App from './App.vue';
+import VueRouter from 'vue-router';
+import routes from './router';
+import store from './store';
+import ElementUI from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+import './public-path.js';
+import dict from '@lib/dict.js';
+import tree from '@lib/tree.js';
+import resChange from '@lib/resChange.js';
+Vue.config.productionTip = false;
+Vue.use(VueRouter);
+Vue.use(ElementUI);
+Vue.use(dict);
+Vue.use(tree);
+Vue.use(resChange);
+let router = null;
+let instance = null;
+function render (props = {}) {
+  const { container } = props;
+  router = new VueRouter({
+    base: window.__POWERED_BY_QIANKUN__ ? '/admin/goods/' : '/',
+    mode: 'history',
+    routes
+  });
+  instance = new Vue({
+    router,
+    store,
+    render: (h) => h(App)
+  }).$mount(container ? container.querySelector('#app') : '#app');
+}
+
+// 独立运行时
+if (!window.__POWERED_BY_QIANKUN__) {
+  render();
+}
+
+export async function bootstrap () {}
+export async function mount (props) {
+  render(props);
+}
+export async function unmount () {
+  instance.$destroy();
+  instance.$el.innerHTML = '';
+  instance = null;
+  router = null;
+}

+ 3 - 0
admin-goods/src/public-path.js

@@ -0,0 +1,3 @@
+if (window.__POWERED_BY_QIANKUN__) {
+  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
+}

+ 10 - 0
admin-goods/src/router/index.js

@@ -0,0 +1,10 @@
+import home from '../views/Home.vue';
+const routes = [
+  {
+    path: '/home',
+    name: 'home',
+    component: home
+  }
+];
+
+export default routes;

+ 55 - 0
admin-goods/src/store/index.js

@@ -0,0 +1,55 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import $axios from '@lib/axios.js';
+const api = {
+  goodsCreate: '/api/goods/goods/create',
+  goodsUpdate: '/api/goods/goods/update',
+  goodsDelete: '/api/goods/goods/delete',
+  goodsQuery: '/api/goods/goods/query',
+  goodsFetch: '/api/goods/goods/fetch'
+};
+Vue.use(Vuex);
+const state = () => ({
+  Total: 0,
+  goodsList: [],
+  columnList: [],
+  dict: {}
+});
+
+const actions = {
+  async goodsCreate ({ commit }, payload) {
+    const res = await $axios.post(api.goodsCreate, payload);
+    return res;
+  },
+  async goodsUpdate ({ commit }, payload) {
+    const res = await $axios.post(api.goodsUpdate, { ...payload, id: payload._id });
+    return res;
+  },
+  async goodsDelete ({ commit }, { id }) {
+    const res = await $axios.delete(`${api.goodsDelete}/${id}`);
+    return res;
+  },
+  async goodsQuery ({ commit }, { filter, paging } = {}) {
+    const res = await $axios.get(api.goodsQuery, { ...filter, skip: paging.page, limit: paging.size });
+    commit('goodsQuery', res);
+    return res;
+  },
+  async goodsFetch ({ commit }, payload) {
+    const res = await $axios.get(api.goodsFetch, payload);
+    return res;
+  }
+};
+
+const mutations = {
+  goodsQuery(state, payload) {
+    state.goodsList = payload.data;
+    state.Total = payload.total;
+  }
+};
+
+export default new Vuex.Store({
+  state,
+  actions,
+  mutations,
+  modules: {}
+});

+ 196 - 0
admin-goods/src/views/Home.vue

@@ -0,0 +1,196 @@
+<template>
+  <div class="box">
+    <el-card class="box-card">
+      <div slot="header" class="clearfix">
+        <span>货品管理</span>
+        <el-button style="float: right; padding: 3px 0" type="text" @click="addgoods">添加货品</el-button>
+      </div>
+      <div class="main">
+        <filterList ref="filterList" :tableData="goodsList" :filed="filed" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total"></filterList>
+      </div>
+    </el-card>
+    <dialogAndDrawer :width="'35%'" :title="title" :visibleSync="visibleSync" v-if="visibleSync" @close="visibleSync = false">
+      <template v-slot:windowMain>
+        <formData ref="formData" :filed="formfiled" :data="formdata" :rules="formrules" @save="formSave" v-if="visibleSync">
+          <template v-slot:formItem="{ item, formdata }">
+            <!-- 富文本 -->
+            <editoritem v-if="item.name == 'content'" @change="editChage" :value="formdata[item.name]"></editoritem>
+            <!-- 缩略图 -->
+            <el-upload
+              v-if="item.name == 'thumbnail'"
+              class="avatar-uploader"
+              action="/api/files/avatar/upload"
+              :show-file-list="false"
+              :headers="myHeaders"
+              :on-success="handleAvatarSuccess"
+              :before-upload="beforeAvatarUpload">
+              <img v-if="formdata[item.name] && formdata[item.name] !== ''" :src="formdata[item.name]" class="avatar">
+              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+            </el-upload>
+          </template>
+        </formData>
+      </template>
+    </dialogAndDrawer>
+  </div>
+</template>
+<script>
+import filterList from '@components/filterList/index.vue';
+import dialogAndDrawer from '@components/dialogAndDrawer.vue';
+import formData from '@components/formData/index.vue';
+import editoritem from '@components/editoritem.vue';
+import { mapState, mapActions } from 'vuex';
+const token = sessionStorage.getItem('token');
+export default {
+  components: {
+    filterList,
+    dialogAndDrawer,
+    formData,
+    editoritem
+  },
+  data() {
+    return {
+      fileList: [],
+      myHeaders: { Authorization: token },
+      title: '',
+      visibleSync: false,
+      filed: [
+        { name: 'name', label: '标题', filter: true },
+        { name: 'describe', label: '描述' }
+      ],
+      formdata: {},
+      formfiled: [
+        { name: 'thumbnail', label: '状态', formater: 'slot' },
+        { name: 'name', label: '标题' },
+        { name: 'describe', label: '描述' },
+        { name: 'content', label: '内容', formater: 'slot' }
+      ],
+      formrules: {
+        thumbnail: [
+          { required: true, message: '请上传缩略图', trigger: 'chage' }
+        ],
+        name: [
+          { required: true, message: '请输入标题', trigger: 'blur' }
+        ],
+        describe: [
+          { required: true, message: '请输入描述', trigger: 'blur' }
+        ],
+        content: [
+          { required: true, message: '请输输入内容', trigger: 'blur' }
+        ]
+      }
+    };
+  },
+  computed: {
+    ...mapState(['goodsList', 'Total', 'journalList'])
+  },
+  async mounted() {
+    await this.filterQuery();
+  },
+  methods: {
+    ...mapActions(['goodsQuery', 'goodsCreate', 'goodsUpdate', 'goodsDelete', 'goodsFetch']),
+    // 添加
+    addgoods () {
+      this.formdata = {};
+      this.title = '添加货品';
+      this.visibleSync = true;
+    },
+    // 修改
+    async filtereEdit (e) {
+      const res = await this.goodsFetch({ id: e._id });
+      this.formdata = res.data;
+      this.title = '修改货品';
+      this.visibleSync = true;
+    },
+    // 删除
+    async filterDelete (e) {
+      const res = await this.goodsDelete({ id: e?._id });
+      this.$resChange(res, '删除成功');
+      this.filterQuery();
+    },
+    // 查询
+    async filterQuery ({ filter = {}, paging = { content: 0, size: 10 } } = {}) {
+      await this.goodsQuery({ filter, paging });
+    },
+    // 表单保存
+    async formSave (e) {
+      if (e.isRevise && e?.isRevise == false) {
+        this.$message.warning('未作修改');
+        return;
+      }
+      this.$delete(e, 'isRevise');
+      let res, msg;
+      // 修改
+      if (e._id) {
+        res = await this.goodsUpdate(e);
+        msg = '货品修改成功';
+      } else {
+        res = await this.goodsCreate(e);
+        msg = '货品添加成功';
+      }
+      this.$resChange(res, msg);
+      this.filterQuery();
+      this.visibleSync = false;
+    },
+    // 富文本改变
+    editChage (e) {
+      this.$refs.formData.setForm('content', e);
+    },
+    // 缩略图上传
+    handleAvatarSuccess(res, file) {
+      this.$refs.formData.setForm('thumbnail', res.data.filePath);
+    },
+    // 缩略图上传限制
+    beforeAvatarUpload(file) {
+      const isJPG = file.type === 'image/jpeg';
+      const isLt2M = file.size / 1024 / 1024 < 2;
+
+      if (!isJPG) {
+        this.$message.error('上传头像图片只能是 JPG 格式!');
+      }
+      if (!isLt2M) {
+        this.$message.error('上传头像图片大小不能超过 2MB!');
+      }
+      return isJPG && isLt2M;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.box {
+  width: 100%;
+  height: 100%;
+  .box-card {
+    height: 100%;
+    .el-card__body {
+      height: 100%;
+    }
+  }
+}
+.el-dialog {
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 120px;
+    height: 120px;
+    line-height: 120px;
+    text-align: center;
+  }
+  .avatar {
+    width: 120px;
+    height: 120px;
+    display: block;
+  }
+}
+</style>
+<style>
+.el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.el-upload:hover {
+  border-color: #409EFF;
+}
+</style>

+ 33 - 0
admin-goods/vue.config.js

@@ -0,0 +1,33 @@
+const path = require('path');
+const frameSrc = path.resolve(__dirname, '../admin-frame');
+const packageName = require('./package.json').name;
+module.exports = {
+  publicPath: `/${packageName}/`,
+  outputDir: path.join(frameSrc, `../../admin-web/${packageName}/`),
+  devServer: {
+    port: 3014,
+    headers: {
+      'Access-Control-Allow-Origin': '*'
+    },
+    proxy: {
+      '/api/': {
+        // target: 'http://192.168.0.45:18090'
+        target: 'http://192.168.3.45:18090'
+      }
+    }
+  },
+  configureWebpack: {
+    output: {
+      library: `${packageName}-[name]`,
+      libraryTarget: 'umd',
+      jsonpFunction: `webpackJsonp_${packageName}`
+    },
+    resolve: {
+      alias: {
+        '@components': path.join(frameSrc, '/src/components'),
+        '@style': path.join(frameSrc, '/style'),
+        '@lib': path.join(frameSrc, '/lib')
+      }
+    }
+  }
+};

+ 0 - 17
admin-journal-catalogue/src/views/home.vue

@@ -189,23 +189,6 @@ export default {
       console.log(123);
       this.$refs.formData.setForm('annex', null);
       delete this.fileList[0];
-    },
-    // 缩略图上传
-    handleAvatarSuccess(res, file) {
-      this.$refs.formData.setForm('thumbnail', res.data.filePath);
-    },
-    // 缩略图上传限制
-    beforeAvatarUpload(file) {
-      const isJPG = file.type === 'image/jpeg';
-      const isLt2M = file.size / 1024 / 1024 < 2;
-
-      if (!isJPG) {
-        this.$message.error('上传头像图片只能是 JPG 格式!');
-      }
-      if (!isLt2M) {
-        this.$message.error('上传头像图片大小不能超过 2MB!');
-      }
-      return isJPG && isLt2M;
     }
   }
 };

+ 1 - 12
admin-journal-intact/src/views/home.vue

@@ -6,18 +6,7 @@
         <el-button style="float: right; padding: 3px 0" type="text" @click="addintact">添加期刊</el-button>
       </div>
       <div class="main">
-        <filterList ref="filterList" :tableData="intact" :filed="filed" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total">
-          <template v-slot:search="{ item, formInline }">
-            <el-select clearable v-if="item.name == 'bind'" v-model="formInline[item.name]" placeholder="请选择">
-              <el-option
-                v-for="i in columnList"
-                :key="i.value"
-                :label="i.name"
-                :value="i.code">
-              </el-option>
-            </el-select>
-          </template>
-        </filterList>
+        <filterList ref="filterList" :tableData="intact" :filed="filed" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total"></filterList>
       </div>
     </el-card>
     <dialogAndDrawer :width="'35%'" :title="title" :visibleSync="visibleSync" v-if="visibleSync" @close="visibleSync = false">

+ 3 - 0
admin-market/.browserslistrc

@@ -0,0 +1,3 @@
+> 1%
+last 2 versions
+not dead

+ 5 - 0
admin-market/.editorconfig

@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 2 - 0
admin-market/.env

@@ -0,0 +1,2 @@
+# 窗口使用弹出还是抽屉 (dialog And drawer)
+VUE_APP_WINDOW=dialog

+ 1 - 0
admin-market/.eslintignore

@@ -0,0 +1 @@
+public-path.js

+ 23 - 0
admin-market/.eslintrc.js

@@ -0,0 +1,23 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/essential',
+    '@vue/standard'
+  ],
+  parserOptions: {
+    parser: 'babel-eslint'
+  },
+  rules: {
+    'no-console': 0,
+    'no-debugger': 0,
+    'comma-dangle': [2, 'never'],
+    'no-extra-parens': 2,
+    'no-extra-semi': 2,
+    semi: [2, 'always'],
+    'space-before-function-paren': [0, 'always'],
+    eqeqeq: 0
+  }
+};

+ 23 - 0
admin-market/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 24 - 0
admin-market/README.md

@@ -0,0 +1,24 @@
+# admin-code
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Lints and fixes files
+```
+npm run lint
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
admin-market/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+};

File diff suppressed because it is too large
+ 12586 - 0
admin-market/package-lock.json


+ 35 - 0
admin-market/package.json

@@ -0,0 +1,35 @@
+{
+  "name": "admin-market",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "core-js": "^3.6.5",
+    "element-ui": "^2.15.6",
+    "vue": "^2.6.11",
+    "vue-router": "^3.2.0",
+    "vuex": "^3.4.0"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.5.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/cli-plugin-router": "~4.5.0",
+    "@vue/cli-plugin-vuex": "~4.5.0",
+    "@vue/cli-service": "~4.5.0",
+    "@vue/eslint-config-standard": "^5.1.2",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-import": "^2.20.2",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-promise": "^4.2.1",
+    "eslint-plugin-standard": "^4.0.0",
+    "eslint-plugin-vue": "^6.2.2",
+    "sass": "^1.45.1",
+    "sass-loader": "^10.0.0",
+    "vue-template-compiler": "^2.6.11"
+  }
+}

BIN
admin-market/public/favicon.ico


+ 17 - 0
admin-market/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 24 - 0
admin-market/src/App.vue

@@ -0,0 +1,24 @@
+<template>
+  <div id="app">
+    <router-view></router-view>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  computed: {},
+  data() {
+    return {};
+  },
+  mounted() {},
+  methods: {}
+};
+</script>
+
+<style lang="scss" scoped>
+#app {
+  width: 100%;
+  height: 100%;
+}
+</style>

BIN
admin-market/src/assets/logo.png


+ 48 - 0
admin-market/src/main.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import App from './App.vue';
+import VueRouter from 'vue-router';
+import routes from './router';
+import store from './store';
+import ElementUI from 'element-ui';
+import 'element-ui/lib/theme-chalk/index.css';
+import './public-path.js';
+import dict from '@lib/dict.js';
+import tree from '@lib/tree.js';
+import resChange from '@lib/resChange.js';
+Vue.config.productionTip = false;
+Vue.use(VueRouter);
+Vue.use(ElementUI);
+Vue.use(dict);
+Vue.use(tree);
+Vue.use(resChange);
+let router = null;
+let instance = null;
+function render (props = {}) {
+  const { container } = props;
+  router = new VueRouter({
+    base: window.__POWERED_BY_QIANKUN__ ? '/admin/market/' : '/',
+    mode: 'history',
+    routes
+  });
+  instance = new Vue({
+    router,
+    store,
+    render: (h) => h(App)
+  }).$mount(container ? container.querySelector('#app') : '#app');
+}
+
+// 独立运行时
+if (!window.__POWERED_BY_QIANKUN__) {
+  render();
+}
+
+export async function bootstrap () {}
+export async function mount (props) {
+  render(props);
+}
+export async function unmount () {
+  instance.$destroy();
+  instance.$el.innerHTML = '';
+  instance = null;
+  router = null;
+}

+ 3 - 0
admin-market/src/public-path.js

@@ -0,0 +1,3 @@
+if (window.__POWERED_BY_QIANKUN__) {
+  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
+}

+ 10 - 0
admin-market/src/router/index.js

@@ -0,0 +1,10 @@
+import home from '../views/Home.vue';
+const routes = [
+  {
+    path: '/home',
+    name: 'home',
+    component: home
+  }
+];
+
+export default routes;

+ 55 - 0
admin-market/src/store/index.js

@@ -0,0 +1,55 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import $axios from '@lib/axios.js';
+const api = {
+  goodsCreate: '/api/goods/goods/create',
+  goodsUpdate: '/api/goods/goods/update',
+  goodsDelete: '/api/goods/goods/delete',
+  goodsQuery: '/api/goods/goods/query',
+  goodsFetch: '/api/goods/goods/fetch'
+};
+Vue.use(Vuex);
+const state = () => ({
+  Total: 0,
+  goodsList: [],
+  columnList: [],
+  dict: {}
+});
+
+const actions = {
+  async goodsCreate ({ commit }, payload) {
+    const res = await $axios.post(api.goodsCreate, payload);
+    return res;
+  },
+  async goodsUpdate ({ commit }, payload) {
+    const res = await $axios.post(api.goodsUpdate, { ...payload, id: payload._id });
+    return res;
+  },
+  async goodsDelete ({ commit }, { id }) {
+    const res = await $axios.delete(`${api.goodsDelete}/${id}`);
+    return res;
+  },
+  async goodsQuery ({ commit }, { filter, paging } = {}) {
+    const res = await $axios.get(api.goodsQuery, { ...filter, skip: paging.page, limit: paging.size });
+    commit('goodsQuery', res);
+    return res;
+  },
+  async goodsFetch ({ commit }, payload) {
+    const res = await $axios.get(api.goodsFetch, payload);
+    return res;
+  }
+};
+
+const mutations = {
+  goodsQuery(state, payload) {
+    state.goodsList = payload.data;
+    state.Total = payload.total;
+  }
+};
+
+export default new Vuex.Store({
+  state,
+  actions,
+  mutations,
+  modules: {}
+});

+ 198 - 0
admin-market/src/views/Home.vue

@@ -0,0 +1,198 @@
+<template>
+  <div class="box">
+    <el-card class="box-card">
+      <div slot="header" class="clearfix">
+        <span>商城管理</span>
+        <el-button style="float: right; padding: 3px 0" type="text" @click="addgoods">上架商品</el-button>
+      </div>
+      <div class="main">
+        <filterList ref="filterList" :tableData="goodsList" :filed="filed" @edit="filtereEdit" @delete="filterDelete" @query="filterQuery" :total="Total"></filterList>
+      </div>
+    </el-card>
+    <dialogAndDrawer :width="'35%'" :title="title" :visibleSync="visibleSync" v-if="visibleSync" @close="visibleSync = false">
+      <template v-slot:windowMain>
+        <formData ref="formData" :filed="formfiled" :data="formdata" :rules="formrules" @save="formSave" v-if="visibleSync">
+          <template v-slot:formItem="{ item, formdata }">
+            <!-- 富文本 -->
+            <editoritem v-if="item.name == 'content'" @change="editChage" :value="formdata[item.name]"></editoritem>
+            <!-- 缩略图 -->
+            <el-upload
+              v-if="item.name == 'thumbnail'"
+              class="avatar-uploader"
+              action="/api/files/avatar/upload"
+              :show-file-list="false"
+              :headers="myHeaders"
+              :on-success="handleAvatarSuccess"
+              :before-upload="beforeAvatarUpload">
+              <img v-if="formdata[item.name] && formdata[item.name] !== ''" :src="formdata[item.name]" class="avatar">
+              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+            </el-upload>
+          </template>
+        </formData>
+      </template>
+    </dialogAndDrawer>
+  </div>
+</template>
+<script>
+import filterList from '@components/filterList/index.vue';
+import dialogAndDrawer from '@components/dialogAndDrawer.vue';
+import formData from '@components/formData/index.vue';
+import editoritem from '@components/editoritem.vue';
+import { mapState, mapActions } from 'vuex';
+const token = sessionStorage.getItem('token');
+export default {
+  components: {
+    filterList,
+    dialogAndDrawer,
+    formData,
+    editoritem
+  },
+  data() {
+    return {
+      fileList: [],
+      myHeaders: { Authorization: token },
+      title: '',
+      visibleSync: false,
+      filed: [
+        { name: 'name', label: '名称', filter: true },
+        { name: 'type', label: '类型' },
+        { name: 'status', label: '状态' },
+        { name: 'money', label: '价格' }
+      ],
+      formdata: {},
+      formfiled: [
+        { name: 'thumbnail', label: '状态', formater: 'slot' },
+        { name: 'name', label: '标题' },
+        { name: 'describe', label: '描述' },
+        { name: 'content', label: '内容', formater: 'slot' }
+      ],
+      formrules: {
+        thumbnail: [
+          { required: true, message: '请上传缩略图', trigger: 'chage' }
+        ],
+        name: [
+          { required: true, message: '请输入标题', trigger: 'blur' }
+        ],
+        describe: [
+          { required: true, message: '请输入描述', trigger: 'blur' }
+        ],
+        content: [
+          { required: true, message: '请输输入内容', trigger: 'blur' }
+        ]
+      }
+    };
+  },
+  computed: {
+    ...mapState(['goodsList', 'Total', 'journalList'])
+  },
+  async mounted() {
+    await this.filterQuery();
+  },
+  methods: {
+    ...mapActions(['goodsQuery', 'goodsCreate', 'goodsUpdate', 'goodsDelete', 'goodsFetch']),
+    // 添加
+    addgoods () {
+      this.formdata = {};
+      this.title = '添加货品';
+      this.visibleSync = true;
+    },
+    // 修改
+    async filtereEdit (e) {
+      const res = await this.goodsFetch({ id: e._id });
+      this.formdata = res.data;
+      this.title = '修改货品';
+      this.visibleSync = true;
+    },
+    // 删除
+    async filterDelete (e) {
+      const res = await this.goodsDelete({ id: e?._id });
+      this.$resChange(res, '删除成功');
+      this.filterQuery();
+    },
+    // 查询
+    async filterQuery ({ filter = {}, paging = { content: 0, size: 10 } } = {}) {
+      await this.goodsQuery({ filter, paging });
+    },
+    // 表单保存
+    async formSave (e) {
+      if (e.isRevise && e?.isRevise == false) {
+        this.$message.warning('未作修改');
+        return;
+      }
+      this.$delete(e, 'isRevise');
+      let res, msg;
+      // 修改
+      if (e._id) {
+        res = await this.goodsUpdate(e);
+        msg = '货品修改成功';
+      } else {
+        res = await this.goodsCreate(e);
+        msg = '货品添加成功';
+      }
+      this.$resChange(res, msg);
+      this.filterQuery();
+      this.visibleSync = false;
+    },
+    // 富文本改变
+    editChage (e) {
+      this.$refs.formData.setForm('content', e);
+    },
+    // 缩略图上传
+    handleAvatarSuccess(res, file) {
+      this.$refs.formData.setForm('thumbnail', res.data.filePath);
+    },
+    // 缩略图上传限制
+    beforeAvatarUpload(file) {
+      const isJPG = file.type === 'image/jpeg';
+      const isLt2M = file.size / 1024 / 1024 < 2;
+
+      if (!isJPG) {
+        this.$message.error('上传头像图片只能是 JPG 格式!');
+      }
+      if (!isLt2M) {
+        this.$message.error('上传头像图片大小不能超过 2MB!');
+      }
+      return isJPG && isLt2M;
+    }
+  }
+};
+</script>
+<style lang="scss" scoped>
+.box {
+  width: 100%;
+  height: 100%;
+  .box-card {
+    height: 100%;
+    .el-card__body {
+      height: 100%;
+    }
+  }
+}
+.el-dialog {
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 120px;
+    height: 120px;
+    line-height: 120px;
+    text-align: center;
+  }
+  .avatar {
+    width: 120px;
+    height: 120px;
+    display: block;
+  }
+}
+</style>
+<style>
+.el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+.el-upload:hover {
+  border-color: #409EFF;
+}
+</style>

+ 33 - 0
admin-market/vue.config.js

@@ -0,0 +1,33 @@
+const path = require('path');
+const frameSrc = path.resolve(__dirname, '../admin-frame');
+const packageName = require('./package.json').name;
+module.exports = {
+  publicPath: `/${packageName}/`,
+  outputDir: path.join(frameSrc, `../../admin-web/${packageName}/`),
+  devServer: {
+    port: 3015,
+    headers: {
+      'Access-Control-Allow-Origin': '*'
+    },
+    proxy: {
+      '/api/': {
+        // target: 'http://192.168.0.45:18090'
+        target: 'http://192.168.3.45:18090'
+      }
+    }
+  },
+  configureWebpack: {
+    output: {
+      library: `${packageName}-[name]`,
+      libraryTarget: 'umd',
+      jsonpFunction: `webpackJsonp_${packageName}`
+    },
+    resolve: {
+      alias: {
+        '@components': path.join(frameSrc, '/src/components'),
+        '@style': path.join(frameSrc, '/style'),
+        '@lib': path.join(frameSrc, '/lib')
+      }
+    }
+  }
+};

+ 6 - 0
xms.code-workspace

@@ -39,6 +39,12 @@
 		{
 			"path": "admin-journal-intact"
 		},
+		{
+			"path": "admin-goods"
+		},
+		{
+			"path": "admin-market"
+		},
 	],
 	"settings": {}
 }