소스 검색

no message

linwenxin 10 달 전
부모
커밋
3970e89e76

+ 44 - 0
src/api/masterAuxiliaryMaterials.js

@@ -0,0 +1,44 @@
+import request, { postBlob } from "@/utils/request";
+
+export function newGetList(data) {
+  return request({
+    url: `/worker/goods/list?moduleId=${data.moduleId}`,
+    method: "post",
+    data
+  });
+}
+
+export function newGetListExport(data, name) {
+  return postBlob({
+    url: "/worker/goods/list/export",
+    data,
+    name
+  });
+}
+
+// 获取辅材信息
+export function getDetail(params) {
+  return request({
+    url: "/worker/goods/detail",
+    method: "post",
+    params
+  });
+}
+
+// 新增辅材
+export function addMaterial(params) {
+  return request({
+    url: "/worker/goods/add",
+    method: "post",
+    data: params
+  });
+}
+
+// 编辑辅材
+export function editMaterial(params) {
+  return request({
+    url: "/worker/goods/edit",
+    method: "post",
+    data: params
+  });
+}

+ 423 - 0
src/views/auxiliaryFittings/auxiliaryDataManagement/masterAuxiliaryMaterials/index.vue

@@ -0,0 +1,423 @@
+<template>
+  <zj-tab-page ref="tabPage" :defaultActives="[{ key: 'list', label: $route.meta.title + '-列表', essential: true }]">
+    <template slot-scope="{ activeKey, data }">
+      <template-page v-if="activeKey == 'list'" ref="pageRef" :get-list="getList" :table-attributes="tableAttributes"
+        :table-events="tableEvents" :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters"
+        :column-parsing="columnParsing" :operation="operation()" :exportList="exportList" :operationColumnWidth="80">
+      </template-page>
+      <div v-if="~['add', 'edit'].indexOf(activeKey)">
+        <div style="box-sizing: border-box;padding: 20px">
+          <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
+            <zj-form-module title="编辑" label-width="180px" :form-data="formData" :form-items="formItems">
+            </zj-form-module>
+            <zj-form-module title="添加辅材" label-width="0px" :form-data="formData" :form-items="formItems2">
+            </zj-form-module>
+          </zj-form-container>
+        </div>
+        <div slot="footer" style="box-sizing: border-box;padding-bottom: 20px; padding-right: 20px;text-align: right">
+          <el-button size="mini" @click="data.removeTab()">取 消</el-button>
+          <el-button size="mini" @click="formConfirm(data.removeTab)" type="primary">确 定</el-button>
+        </div>
+        <selectGoods v-if="formVisible" @close="close" @confirm="confirm"
+          :guolvList="(formData.items || []).map(item => item.websitGoodsId)" />
+      </div>
+    </template>
+  </zj-tab-page>
+</template>
+
+<script>
+import {
+  newGetList,
+  newGetListExport,
+  getDetail,
+  addMaterial,
+  editMaterial
+} from "@/api/masterAuxiliaryMaterials"
+import selectGoods from './selectGoods.vue'
+import TemplatePage from '@/components/template/template-page-1.vue'
+import import_mixin from '@/components/template/import_mixin.js'
+import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
+import { materialCategoryTree } from '@/api/auxiliaryMaterialClass'
+import { getTypeList } from '@/api/auxiliaryFittings/attachmentProfile'
+import { commonTemplateDownload } from '@/api/common.js'
+import operation_mixin from '@/components/template/operation_mixin.js'
+import { downloadFiles } from '@/utils/util'
+export default {
+  components: { TemplatePage, selectGoods },
+  mixins: [import_mixin, operation_mixin],
+  data() {
+    return {
+      // 表格属性
+      tableAttributes: {
+        // 启用勾选列
+        selectColumn: true
+      },
+      // 表格事件
+      tableEvents: {
+        'selection-change': this.selectionChange
+      },
+      // 勾选选中行
+      recordSelected: [],
+      /** 表单变量 */
+      formDialogType: 0,
+      formDialogTitles: ['新增', '编辑'],
+      formDialog: false,
+      formData: {
+        companyWechatName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
+        categoryId: '',
+        companyWechatId: '',
+        "goodsCode": "",
+        "goodsId": "",
+        "goodsName": "",
+        "isSmall": true,
+        "items": [],
+        "remark": "",
+        "salesUnit": "",
+        "status": "",
+      },
+      partsUnitList: [],
+      materialCategoryTree: [],
+      formType: 'add',
+      formVisible: false,
+    }
+  },
+  computed: {
+    // 事件组合
+    optionsEvensGroup() {
+      return [
+        [
+          [
+            this.optionsEvensAuth('add', {
+              click: () => {
+                this.openForm("add");
+              }
+            })
+          ]
+        ],
+        [
+          [
+            this.optionsEvensAuth('export2', {
+              click: () => {
+                this.exportSheet2();
+              }
+            })
+          ]
+        ]
+      ]
+    },
+    // 更多参数
+    moreParameters() {
+      return []
+    },
+    formItems() {
+      return [
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-input',
+          attributes: { placeholder: '请输入', disabled: true },
+          formItemAttributes: {
+            label: '所属商户',
+            prop: 'companyWechatName',
+            rules: [...required]
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-radio',
+          options: [
+            { label: '上架', value: 'ON' },
+            { label: '下架', value: 'OFF' }
+          ],
+          attributes: {},
+          formItemAttributes: {
+            label: '状态',
+            prop: 'status',
+            rules: [...required]
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-cascader',
+          attributes: {
+            style: 'width:100%',
+            placeholder: '请输入',
+            options: this.materialCategoryTree,
+            'show-all-levels': false,
+            props: { value: 'categoryId', label: 'categoryName', children: 'child', emitPath: false },
+            clearable: true
+          },
+          formItemAttributes: {
+            label: '选择分类',
+            prop: 'categoryId',
+            rules: [...required]
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-input',
+          attributes: { placeholder: '请输入' },
+          formItemAttributes: {
+            label: '辅材名称',
+            prop: 'goodsName',
+            rules: [...required]
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-select-add',
+          labelKey: 'dictValue',
+          valueKey: 'dictValue',
+          options: this.partsUnitList,
+          attributes: { placeholder: '请选择单位', filterable: true, clearable: true },
+          formItemAttributes: {
+            label: '单位',
+            prop: 'salesUnit',
+            rules: [...required]
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-input',
+          attributes: { placeholder: '请输入' },
+          formItemAttributes: {
+            label: '商品代码',
+            prop: 'goodsCode',
+            rules: []
+          }
+        },
+        {
+          md: 6,
+          isShow: true,
+          name: 'el-radio',
+          options: [
+            { label: '是', value: true },
+            { label: '否', value: false }
+          ],
+          attributes: {},
+          formItemAttributes: {
+            label: '是否小件',
+            prop: 'isSmall',
+            rules: [...required]
+          }
+        },
+        {
+          md: 24,
+          isShow: true,
+          name: 'el-input',
+          attributes: { placeholder: '请输入', type: 'textarea', rows: 5 },
+          formItemAttributes: {
+            label: '备注',
+            prop: 'remark',
+            rules: []
+          }
+        }
+      ]
+    },
+    formItems2() {
+      return [{
+        name: 'slot-component',
+        md: 24,
+        formItemAttributes: {
+          'label-width': '0px',
+          label: '',
+          prop: 'items',
+          rules: [...required]
+        },
+        render: (h, { props }) => {
+          return (
+            <div>
+              <div>
+                <el-button
+                  size="mini"
+                  type="primary"
+                  onClick={() => {
+                    this.formVisible = true
+                  }}
+                >
+                  新增
+                </el-button>
+              </div>
+              <zj-table columns={[{
+                columnAttributes: {
+                  label: '大类名称',
+                  prop: 'parentCategoryName',
+                }
+              },
+              {
+                columnAttributes: {
+                  label: '小类名称',
+                  prop: 'goodsCategoryName',
+                }
+              }, {
+                columnAttributes: {
+                  label: '辅材名称',
+                  prop: 'websitGoodsName',
+                }
+              }, {
+                columnAttributes: {
+                  label: '单位',
+                  prop: 'goodsSalesUnit',
+                }
+              }, {
+                columnAttributes: {
+                  label: '商品代码',
+                  prop: 'goodsCode',
+                }
+              }, {
+                columnAttributes: {
+                  label: '规格型号',
+                  prop: 'goodsSpecification',
+                }
+              }, {
+                columnAttributes: {
+                  label: '操作',
+                  prop: '',
+                },
+                render: (h, { row, column, index }) => {
+                  return (
+                    <div style="padding: 0 10px">
+                      <el-button
+                        size="mini"
+                        type="text"
+                        onClick={() => {
+                          this.formData.items.splice(index, 1)
+                        }}
+                      >
+                        删除
+                      </el-button>
+                    </div>
+                  )
+                }
+              }]} table-data={this.formData.items || []} />
+            </div>
+          )
+        }
+      }]
+    },
+  },
+  methods: {
+    // 列表请求函数
+    getList: newGetList,
+    // 列表导出函数
+    exportList: newGetListExport,
+    // 表格列解析渲染数据更改
+    columnParsing(item, defaultData) {
+      return defaultData
+    },
+    // 监听勾选变化
+    selectionChange(data) {
+      this.recordSelected = data
+    },
+    operation() {
+      return this.operationBtn({
+        // view: {
+        //   click: ({ row, index, column }) => {
+        //     this.openForm('edit', row.goodsId)
+        //   }
+        // },
+        edit: {
+          click: ({ row, index, column }) => {
+            this.openForm('edit', row.goodsId)
+          }
+        }
+      })
+    },
+    openForm(type, id) {
+      this.$refs.tabPage.addTab({
+        // 对应显示的模块
+        activeKey: type,
+        // 唯一标识
+        key: type,
+        // 页签名称
+        label: { edit: '编辑', add: '新增' }[type],
+        // 打开时事件
+        triggerEvent: () => {
+          this.formCancel()
+          this.$nextTick(() => {
+            this.formType = type
+            Promise.all([
+              getTypeList({
+                pageNum: 1,
+                pageSize: -1,
+                params: [
+                  { param: 'a.dict_type', compare: '=', value: `ASSIST_UNIT` },
+                  { param: 'a.status', compare: '=', value: 'ON' }
+                ]
+              }),
+              materialCategoryTree({ state: 'ON' })
+            ]).then(([res1, res2]) => {
+              this.partsUnitList = res1.data.records
+              this.materialCategoryTree = res2.data.filter(item => item.child && item.child.length > 0)
+              this.formDialog = true
+            })
+            if (type == 'add') {
+              this.formDialogType = 0
+            } else if (type == 'edit') {
+              this.formDialogType = 1
+              getDetail({ id }).then(res => {
+                Object.assign(this.formData, res.data)
+              })
+            }
+          })
+        },
+        // 关闭时事件
+        closeEvent: () => {
+          this.formCancel()
+        }
+      })
+    },
+    formCancel() {
+      this.formVisible = false
+      this.$refs?.formRef?.resetFields()
+      this.$data.formData = this.$options.data().formData
+    },
+    formConfirm(cancel) {
+      this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
+        if (valid) {
+          ;[addMaterial, editMaterial][this.formDialogType](this.formData).then(res => {
+            this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
+            cancel('list')
+            this.$refs.pageRef.refreshList()
+          })
+        }
+      })
+    },
+    setNumber(val) {
+      return Number(val.toFixed(2))
+    },
+    close() {
+      this.formVisible = false
+    },
+    confirm(data) {
+      data.filter(val => !~this.formData.items.map(item => item.websitGoodsId).indexOf(val.goodsId)).map(item => {
+        this.formData.items.push({
+          "goodsCategoryId": item.goodsCategoryId,
+          "goodsCategoryName": item.categoryName,
+          "goodsCode": item.goodsCode,
+          "goodsSalesUnit": item.goodsStockUnit,
+          "goodsSpecification": item.goodsSpecification,
+          "parentCategoryId": item.parentCategoryId,
+          "parentCategoryName": item.parentCategoryName,
+          "websitGoodsId": item.goodsId,
+          "websitGoodsName": item.goodsName,
+          "workerGoodsId": "",
+          "workerGoodsName": ""
+        })
+      })
+      this.close()
+    },
+    // 导出
+    exportSheet2() {
+      downloadFiles("worker/goods/rela/export", {});
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped></style>

+ 150 - 0
src/views/auxiliaryFittings/auxiliaryDataManagement/masterAuxiliaryMaterials/selectGoods.vue

@@ -0,0 +1,150 @@
+<template>
+  <el-dialog width="980px" title="商品列表" :visible.sync="innerVisible" append-to-body :close-on-click-modal="false"
+    @close="$emit('close')">
+    <div class="screen-container">
+      <el-form ref="tableScreenForm" :model="tableScreenForm" label-width="70px" size="small" label-position="left">
+        <el-row :gutter="20">
+          <el-col :xs="24" :sm="8" :lg="8">
+            <el-form-item label="辅材编号" prop="goodsId">
+              <el-input v-model="tableScreenForm.goodsId" placeholder="辅材编号" size="small" />
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="8" :lg="8">
+            <el-form-item label="辅材名称" prop="goodsName">
+              <el-input v-model="tableScreenForm.goodsName" placeholder="辅材名称" size="small" />
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="8" :lg="8">
+            <el-form-item label="辅材小类" prop="categoryId">
+              <el-cascader v-model="tableScreenForm.categoryId" placeholder="辅材小类" size="small" :show-all-levels="false"
+                clearable
+                :props="{ options: materialCategoryTree, value: 'categoryId', label: 'categoryName', children: 'child', emitPath: false }">
+              </el-cascader>
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="8" :lg="8">
+            <el-form-item label="商品代码" prop="goodsCode">
+              <el-input v-model="tableScreenForm.goodsCode" placeholder="商品代码" size="small" />
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="8" :lg="8">
+            <el-form-item label="规格型号" prop="goodsSpecification">
+              <el-input v-model="tableScreenForm.goodsSpecification" placeholder="规格型号" size="small" />
+            </el-form-item>
+          </el-col>
+          <el-col :xs="24" :sm="8" :lg="8" class="tr">
+            <el-form-item label="">
+              <el-button size="small" type="primary" @click="getGoodsListByScreen">搜索</el-button>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+    <el-table ref="goodsTable" :data="goodsList" :row-key="getRowKeys" height="350" size="mini" border
+      header-cell-class-name="headerRowColor" style="width: 100%" @selection-change="handleChooseGoods">
+      <el-table-column type="selection" width="55" :reserve-selection="true" :selectable="selectable" />
+      <el-table-column prop="parentCategoryName" label="大类类名称" />
+      <el-table-column prop="categoryName" label="小类名称" />
+      <el-table-column prop="goodsName" label="辅材名称" />
+      <el-table-column prop="goodsStockUnit" label="单位" />
+      <el-table-column prop="goodsSpecification" label="规格型号" />
+      <el-table-column prop="remark" label="备注" />
+    </el-table>
+    <div class="pagination clearfix" style="margin-top: 20px">
+      <div class="fr">
+        <el-pagination :current-page="table_currentPage" :page-size="table_pageSize" background
+          layout="prev, pager, next" :total="table_listTotal" @current-change="handleTableCurrentChange" />
+      </div>
+    </div>
+    <div slot="footer" class="dialog-footer">
+      <el-button type="primary" @click="selGoods">确 定</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { materialCategoryTree } from '@/api/auxiliaryMaterialClass'
+import { materialNormList } from "@/api/auxiliaryPriceManagement";
+export default {
+  props: {
+    guolvList: {
+      type: Array,
+      default: () => []
+    }
+  },
+  data() {
+    return {
+      innerVisible: true,
+      tableScreenForm: {
+        goodsId: "",
+        goodsName: "",
+        goodsCode: "",
+        categoryId: "",
+        goodsSpecification: ""
+      },
+      goodsList: [],
+      table_currentPage: 1,
+      table_pageSize: 10,
+      table_listTotal: 0,
+      table_chooseGoods: [],
+      materialCategoryTree: []
+    }
+  },
+  created() {
+    // 获取小类筛选
+    materialCategoryTree({ state: 'ON' }).then((res2) => {
+      this.materialCategoryTree = res2.data.filter(item => item.child && item.child.length > 0)
+    })
+    // 获取列表数据
+    this.getGoodsList();
+  },
+  methods: {
+    selectable(row, index) {
+      return !~this.guolvList.indexOf(row.goodsId)
+    },
+    // 获取商品列表
+    getGoodsList() {
+      materialNormList({
+        "pageNum": this.table_currentPage,
+        "pageSize": this.table_pageSize,
+        "params": [
+          ...(() => { if (this.tableScreenForm.goodsId) { return [{ "param": "a.goods_id", "compare": "like", "value": this.tableScreenForm.goodsId }] } else { return [] } })(),
+          ...(() => { if (this.tableScreenForm.goodsName) { return [{ "param": "a.goods_name", "compare": "like", "value": this.tableScreenForm.goodsName }] } else { return [] } })(),
+          ...(() => { if (this.tableScreenForm.goodsCode) { return [{ "param": "a.goods_code", "compare": "like", "value": this.tableScreenForm.goodsCode }] } else { return [] } })(),
+          ...(() => { if (this.tableScreenForm.goodsSpecification) { return [{ "param": "a.goods_specification", "compare": "like", "value": this.tableScreenForm.goodsSpecification }] } else { return [] } })(),
+          ...(() => { if (this.tableScreenForm.categoryId) { return [{ "param": "b.category_id", "compare": "=", "value": this.tableScreenForm.categoryId }] } else { return [] } })(),
+        ]
+      }).then(res => {
+        this.goodsList = res.data.records;
+        this.table_listTotal = res.data.total;
+      });
+    },
+    // 搜索
+    getGoodsListByScreen() {
+      this.handleTableCurrentChange(1)
+    },
+    // 更改列表当前页
+    handleTableCurrentChange(val) {
+      if (this.table_chooseGoods.length > 0) {
+        return this.$errorMsg("当前已选择商品");
+      }
+      this.table_currentPage = val;
+      this.getGoodsList();
+    },
+    // id
+    getRowKeys(row) {
+      return row.goodsId;
+    },
+    // table点击选择商品
+    handleChooseGoods(val) {
+      this.table_chooseGoods = val;
+    },
+    selGoods() {
+      console.log(this.table_chooseGoods)
+      this.$emit('confirm', this.table_chooseGoods)
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped></style>