Browse Source

对接调拨类型管理

chenrui 4 years ago
parent
commit
4ccd49069b

+ 39 - 0
src/api/allocateType.js

@@ -0,0 +1,39 @@
+import { axios } from '@/utils/request'
+
+//  调拨类型管理 列表  分页
+export const allocateTypeList = (params) => {
+  const url = `/allocateType/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 调拨类型管理  新增/编辑
+export const allocateTypeSave = params => {
+  return axios({
+    url: '/allocateType/save',
+    data: params,
+    method: 'post'
+  })
+}
+
+// 调拨类型管理  删除
+export const allocateTypeDel = params => {
+  return axios({
+    url: `/allocateType/delete/${params.sn}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 调拨类型管理  详情
+export const allocateTypeDetail = params => {
+  return axios({
+    url: `/allocateType/findBySn/${params.sn}`,
+    data: {},
+    method: 'get'
+  })
+}

+ 2 - 2
src/config/router.config.js

@@ -1520,8 +1520,8 @@ export const asyncRouterMap = [
         component: PageView,
         meta: {
           title: '基础设置',
-          icon: 'pushpin',
-          permission: 'M_basicData'
+          icon: 'pushpin'
+          // permission: 'M_basicData'
         },
         children: [
           {

+ 152 - 0
src/views/basicData/transferTypeManagement/editModal.vue

@@ -0,0 +1,152 @@
+<template>
+  <a-modal
+    centered
+    class="transferTypeManagementEdit-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="modalTit"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="800">
+    <!-- 表单 -->
+    <div>
+      <a-form-model
+        id="transferTypeManagementEdit-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="调拨类别" prop="allocateCategory">
+          <v-select code="ALLOCATE_CATEGORY" id="transferTypeManagementEdit-allocateCategory" v-model="form.allocateCategory" allowClear placeholder="请选择调拨类别"></v-select>
+        </a-form-model-item>
+        <a-form-model-item label="调拨类型名称" prop="name">
+          <a-input
+            id="transferTypeManagementEdit-name"
+            :maxLength="30"
+            v-model.trim="form.name"
+            @change="filterEmpty"
+            placeholder="请输入调拨类型名称(最多30个字符)"
+            allowClear />
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="storeTransferOut-type-edit-modal-save" @click="handleSave">保存</a-button>
+        <a-button id="storeTransferOut-type-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { VSelect } from '@/components'
+import { allocateTypeSave } from '@/api/allocateType'
+export default {
+  name: 'TransferTypeManagementEditModal',
+  components: { VSelect },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
+    },
+    nowData: {
+      type: Object,
+      default: null
+    }
+  },
+  computed: {
+    modalTit () {
+      return (this.itemSn ? '编辑' : '新增') + '调拨类型'
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      detailsData: null, //  品牌数据
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        name: '', // 调拨类型名称
+        allocateCategory: undefined //  调拨类别
+      },
+      rules: {
+        name: [
+          { required: true, message: '请输入调拨类型名称', trigger: 'blur' }
+        ],
+        allocateCategory: [
+          { required: true, message: '请选择调拨类别', trigger: 'change' }
+        ]
+      }
+    }
+  },
+  methods: {
+    filterEmpty () {
+      let str = this.form.name
+      str = str.replace(/\ +/g, '')
+      str = str.replace(/[ ]/g, '')
+      str = str.replace(/[\r\n]/g, '')
+      this.form.name = str
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const form = _this.form
+          form.id = _this.itemSn ? _this.itemSn : null
+          allocateTypeSave(form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.isShow = false
+            }
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      }
+    },
+    itemSn (newValue, oldValue) {
+      if (this.isShow && newValue) { //  编辑
+        this.form.name = this.nowData && this.nowData.name ? this.nowData.name : ''
+        this.form.allocateCategory = this.nowData && this.nowData.allocateCategory ? this.nowData.allocateCategory : ''
+      } else { //  添加
+        this.form.name = ''
+        this.form.allocateCategory = undefined
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .transferTypeManagementEdit-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>

+ 100 - 3
src/views/basicData/transferTypeManagement/list.vue

@@ -1,8 +1,105 @@
 <template>
+  <a-card size="small" :bordered="false" class="transferTypeManagementList-wrap">
+    <!-- 操作按钮 -->
+    <div class="table-operator-nobor">
+      <a-button
+        id="transferTypeManagementList-add"
+        type="primary"
+        class="button-error"
+        @click="handleEdit()">新增</a-button>
+    </div>
+    <!-- 列表 -->
+    <s-table
+      class="sTable"
+      ref="table"
+      size="default"
+      :rowKey="(record) => record.id"
+      :columns="columns"
+      :data="loadData"
+      :scroll="{ y: 300 }"
+      bordered>
+      <!-- 操作 -->
+      <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-info"
+          @click="handleEdit(record)"
+          id="transferTypeManagementList-edit-btn">编辑</a-button>
+        <a-button
+          size="small"
+          type="link"
+          class="button-error"
+          @click="handleDel(record)"
+          id="transferTypeManagementList-del-btn">删除</a-button>
+      </template>
+    </s-table>
+    <!-- 新增/编辑 -->
+    <transfer-type-management-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @close="closeModal" />
+  </a-card>
 </template>
 
 <script>
+import { STable, VSelect } from '@/components'
+import transferTypeManagementEditModal from './editModal.vue'
+import { allocateTypeList, allocateTypeDel } from '@/api/allocateType'
+export default {
+  components: { STable, VSelect, transferTypeManagementEditModal },
+  data () {
+    return {
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
+        { title: '调拨类别', dataIndex: 'allocateCategoryDictValue', width: 200, align: 'center' },
+        { title: '调拨类型名称', dataIndex: 'name', align: 'center', ellipsis: true },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        return allocateTypeList(Object.assign(parameter, {})).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          return data
+        })
+      },
+      openModal: false, //  新增编辑调拨类型  弹框
+      itemSn: '', //  当前sn
+      nowData: null //  当前记录数据
+    }
+  },
+  methods: {
+    //  新增/编辑
+    handleEdit (row) {
+      this.itemSn = row ? row.allocateTypeSn : null
+      this.nowData = row || null
+      this.openModal = true
+    },
+    //  删除
+    handleDel (row) {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '删除后原数据不可恢复,是否删除?',
+        centered: true,
+        onOk () {
+          allocateTypeDel({ sn: row.allocateTypeSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    },
+    //  关闭弹框
+    closeModal () {
+      this.itemSn = ''
+      this.openModal = false
+      this.$refs.table.refresh(true)
+    }
+  }
+}
 </script>
-
-<style>
-</style>