123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612 |
- <template>
- <div class="my-container">
- <!-- <transition-group name="fade" style="position: relative;width: 100%;display: flex;"> -->
- <div class="bill-left" v-show="isShow==='home'" key="item">
- <div class="bill-tab">
- <div class="bill-title">导航</div>
- <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
- </div>
- </div>
- <div class="bill-main" v-show="isShow==='home'" key="item2">
- <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
- @resert="onRefresh" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
- </module-view>
- </div>
- <!-- 新增/编辑弹窗 -->
- <div class="detil" v-show="isShow==='add'" key="item3">
- <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
- <div class="box-shadow">
- <by-form :propConfig="addConfig" ref="addFormId">
- <template v-slot:k3ServerUrl="{value}" class="clearfix">
- <!-- <i class="el-icon-question" title="私有云必须配置金蝶云星空产品地址,K3Cloud/结尾,若为公有云则必须置空"></i> -->
- <!-- <vxe-input v-model="value.k3ServerUrl" style="width:calc(100% - 25px);margin-left: 10px;"></vxe-input> -->
- <vxe-input v-model="value.k3ServerUrl" style="width: 27.2%;"></vxe-input>
- <div style="display: inline-block;margin-left: 17px;color: #ababab;">
- <span style="color: red;margin-right: 5px;">*</span>私有云必须配置金蝶云星空产品地址,K3Cloud/结尾,若为公有云则必须置空
- </div>
- </template>
- <template v-slot:status class="clearfix">
- <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
- <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
- </template>
- </by-form>
- </div>
- </div>
- <!-- </transition-group> -->
- </div>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/currency";
- import Assembly from "@/components/Assembly/material.vue";
- @Component
- export default class Supplier extends Vue {
- isShow = 'home'
- timeNum = 0;
- timer : any = null
- popTitle : any = ''
- radio : any = 0
- dialogFormVisible : boolean = false
- categoryIds : any = '';
- toolConfig = {
- tools: {
- return: true,
- save: true,
- }
- }
- treeConfig = {
- attr: {
- retConfig: {
- id: 'id',
- },
- defaultExpandAll: true,
- label: 'name',
- // resType: 'data'
- },
- // request: {
- // url: '/maindata/maindataOrganizationCategory/treeUseList',
- // method: 'GET'
- // }
- }
- config : any = {
- attr: {
- calculateH: true
- },
- search: {
- attr: {
- size: 'mini'
- },
- columns: [
- [{
- span: 6,
- label: '名称',
- prop: 'name',
- component: 'by-input',
- labelWidth: '70px',
- compConfig: {
- attr: {
- placeholder: '请输入名称',
- clearable: true
- },
- },
- }, {
- span: 6,
- label: '负责人',
- prop: 'contacts',
- component: 'by-input',
- labelWidth: '70px',
- compConfig: {
- attr: {
- placeholder: '请输入负责人',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- labelWidth: '70px',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- size: 'small',
- data: [{
- value: 0,
- label: '正常'
- }, {
- value: 1,
- label: '禁用'
- }]
- }
- }
- },
- ]
- ]
- },
- tool: {
- tools: {
- add: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- size: 'mini',
- align: 'left',
- },
- columns: [{
- title: '名称',
- field: 'name',
- isDetail: true,
- width: 150,
- },
- {
- title: '负责人',
- field: 'contacts',
- width: 120,
- },
- {
- title: '联系电话',
- field: 'phonenum',
- width: 150,
- },
- {
- title: '手机号码',
- field: 'telephone',
- width: 150,
- },
- // {
- // width: 300,
- // title: '财务系统类型',
- // field: 'financeType2',
- // },
- {
- width: 80,
- title: '状态',
- field: 'status',
- component: Assembly,
- }, {
- width: 120,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-edit',
- name: '编辑',
- audit: '',
- event: {
- click: (item : any) => {
- (this as any).openEdit(item)
- }
- }
- }, {
- name: '删除',
- event: {
- click: (item : any) => (this as any).doDelete(item)
- }
- }]
- }]
- },
- }
- addConfig = {
- attr: {
- size: 'medium',
- rules: {
- categoryName: [{
- required: true, message: '请选择机构分类', trigger: 'change'
- }],
- name: [{
- required: true, message: '请输入名称', trigger: 'blur'
- }],
- contacts: [{
- required: true, message: '请输入负责人', trigger: 'blur'
- }],
- telephone: [{
- required: true, message: '请输入手机号码', trigger: 'blur'
- }],
- // financeType: [{
- // required: true, message: '请输入财务系统类型', trigger: 'change'
- // }],
- province: [{
- required: true, message: '请选择地址', trigger: 'change'
- }],
- address: [{
- required: true, message: '请输入详细地址', trigger: 'blur'
- }],
- }
- },
- columns: [
- [
- {
- span: 6,
- label: '机构分类',
- prop: 'categoryName',
- component: 'select-tree',
- compConfig: {
- attr: {
- label: 'name',
- clearable: true,
- retConfig: {
- categoryId: 'id',
- categoryName: 'name',
- },
- defaultExpandAll: true
- },
- request: {
- url: '/maindata/maindataOrganizationCategory/treeUseList'
- }
- }
- },
- {
- span: 6,
- label: '名称',
- prop: 'name',
- component: 'by-input',
- },
- {
- span: 6,
- label: '负责人',
- prop: 'contacts',
- component: 'by-input',
- },
- {
- span: 6,
- label: '机构代码',
- prop: 'organizationCode',
- component: 'by-input',
- }
- ],
- [{
- span: 6,
- label: '手机号码',
- prop: 'telephone',
- component: 'by-input',
- },{
- span: 6,
- label: '联系电话',
- prop: 'phonenum',
- component: 'by-input',
- },
- {
- span: 6,
- label: '电子邮箱',
- prop: 'email',
- component: 'by-input',
- },
- ],
- [
- {
- span: 6,
- labelWidth: '110px',
- label: '财务系统类型',
- prop: 'financeType',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择财务系统类型',
- clearable: true,
- size: 'small',
- data: [
- {
- value: 'kingdee',
- label: '金蝶K3'
- },
- // {
- // value: 'yonbip',
- // label: '用友U8'
- // },
- ]
- }
- }
- },
- ],
- [
- {
- span: 18,
- label: 'URL地址',
- slot: true,
- prop: 'k3ServerUrl',
- },
- ],
- [
- {
- span: 6,
- label: '登录授权ID',
- slot: true,
- prop: 'k3AppId',
- component: 'by-input',
- },
- {
- span: 6,
- label: '用户名称',
- slot: true,
- prop: 'k3UserName',
- component: 'by-input',
- },
- {
- span: 6,
- label: '数据中心ID',
- slot: true,
- prop: 'k3AcctId',
- component: 'by-input',
- },
- {
- span: 6,
- label: '应用秘钥',
- slot: true,
- prop: 'k3AppSec',
- component: 'by-input',
- },
- ],
- [{
- span: 18,
- label: '地址',
- prop: 'province',
- component: 'by-area',
- labelWidth: '100px',
- compConfig: {
- attr: {
- province: 'province', //省
- provinceCode: 'provinceCode', //省编码
- city: 'city', //市
- cityCode: 'cityCode', //市编码
- county: 'region', //县/区
- countyCode: 'regionCode', //县/区编码
- town: 'street', //街道
- townCode: 'streetCode', //街道编码
- }
- }
- }],
- [
- {
- span: 18,
- label: '详细地址',
- slot: true,
- prop: 'address',
- component: 'by-input',
- },
- ],
- [
- {
- span: 6,
- label: '状态',
- slot: true,
- prop: 'status',
- },
- ]
- ]
- }
- mounted() {
- this.timer = setInterval(() => {
- this.getDataList()
- }, 300)
- }
- //点击树获取数据
- onChangeTree(e : any) {
- this.categoryIds = e.id;
- var ids:any = e.id;
- if(e.id[0]==0) ids = 0;
- let loading = this.$loading({ target: '.main-container' });
- api.byCategoryPage({ categoryId: ids, type: 2 }, 'maindataOrganizationCategory').then((res : any) => {
- if (res.code === 200) {
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.moduleView as any).setPage(page);
- loading.close();
- } else loading.close();
- }).catch(() => loading.close());
- }
- // 内页工具栏方法
- insideTools(e : any) {
- console.log(e);
- if (e === 'onReturn') this.isShow = 'home';
- if (e === 'onSave') this.confirm();
- }
- // 保存新增/编辑
- confirm() {
- (this as any).$refs.addFormId.validate().then(() => {
- let query = (this as any).$refs.addFormId.getValue();
- query.status = this.radio;
- // 手机验证
- let reg = /^1[3456789]\d{9}$/;
- // let reg2 = /^0\d{2,3}-\d{7,8}$/;
- if (query.telephone && !reg.test(query.telephone)) return this.$message.warning('请输入正确手机号码');
- // if (query.phonenum && !reg2.test(query.phonenum)) return this.$message.warning('请输入正确联系电话');
- if(query.phonenum){
- if (query.phonenum.length>20 || query.phonenum[0]==' ') {
- return this.$message.warning('请输入正确联系电话');
- }
- }
- if (!query.telephone) query.telephone = null;
- if (!query.phonenum) query.phonenum = null;
- let loading = this.$loading({ target: '.main-container' });
- if (this.popTitle === '新增') {
- api.saveList(query, 'maindataMaterialDistributor').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('保存成功');
- // (this as any).$refs.sideTree.request();
- this.isShow = 'home'; // 展示类型
- this.dialogFormVisible = false;
- this.getDataList();
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- } else if (this.popTitle === '编辑') {
- api.updateList(query, 'maindataMaterialDistributor').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('编辑成功');
- // (this as any).$refs.sideTree.request();
- this.isShow = 'home'; // 展示类型
- this.dialogFormVisible = false;
- this.getDataList();
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- }
- }).catch(() => {});
- }
- // 获取列表数据
- getDataList() {
- if (!this.$refs.moduleView) {
- if (this.timeNum > 5) {
- clearInterval(this.timer)
- }
- this.timeNum++;
- return
- }
- clearInterval(this.timer)
- let query = (this.$refs.moduleView as any).getQuery();
- if (this.categoryIds) query.categoryIds = this.categoryIds;
- console.log('表单字段 ==> ', query);
- this.getPageList(query)
- }
- getPageList(query : any) {
- let loading = this.$loading({ target: '.main-container' });
- api.treeList('maindataOrganizationCategory').then((treeRes : any) => {
- if(treeRes.code==200){
- api.pageList(query, 'maindataMaterialDistributor').then((res : any) => {
- loading.close();
- if (res.code === 200) {
-
- var data:any = [{
- id: 0,
- name: '机构分类',
- children: treeRes.data
- }];
- (this as any).$refs.sideTree.setData(data);
-
- res.data.records.map((v : any) => {
- if (v.financeType === 'kingdee') v.financeType2 = '金蝶K3';
- if (v.financeType === 'yonbip') v.financeType2 = '用友U8';
- });
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.moduleView as any).setPage(page);
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- }
- }).catch(() => loading.close());
- }
- // 工具栏方法
- clickHandle(e : any) {
- if (e === 'onAdd') this.onAdd();
- }
- // 打开新增
- onAdd() {
- this.isShow = 'add'; // 展示类型
- this.popTitle = '新增'
- this.dialogFormVisible = true;
- this.radio = 0
- this.$nextTick(() => (this as any).$refs.addFormId.setValue());
- }
- // 打开编辑
- openEdit(e : any) {
- // console.log('打开编辑 ==> ', e);
- this.isShow = 'add'; // 展示类型
- this.popTitle = '编辑'
- let loading = this.$loading({ target: '.main-container' });
- api.single({ id: e.id }, 'maindataMaterialDistributor').then((res : any) => {
- if (res.code === 200) {
- let data = res.data;
- this.radio = data.status;
- this.dialogFormVisible = true;
- this.$nextTick(() => (this as any).$refs.addFormId.setValue(data));
- loading.close();
- } else loading.close();
- }).catch(() => loading.close());
- }
- // 操作删除
- doDelete(item : any) {
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.deleteList({ ids: item.id }, 'maindataMaterialDistributor').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- // (this as any).$refs.sideTree.request();
- this.getDataList();
- this.$message.success('删除成功');
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消删除'));
- }
- // 刷新/重置
- onRefresh() {
- (this as any).$refs.moduleView.clearSearch();
- // (this as any).$refs.sideTree.request();
- this.categoryIds = '';
- this.getDataList();
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-container {
- width: 100%;
- box-sizing: border-box;
- display: flex;
- padding: 16px;
- height: 100%;
- .bill-left {
- position: relative;
- border-right: solid #EEE 1px;
- padding-right: 16px;
- flex-shrink: 0;
- .bill-tab {
- width: 210px;
- height: 100%;
- transition: all .5s;
- overflow: auto;
- }
- .tab-title {
- font-size: 16px;
- padding-bottom: 16px;
- width: 200px;
- }
- }
- .bill-main {
- width: calc(100% - 16px);
- box-sizing: border-box;
- margin-left: 16px;
- position: relative;
- height: 100%;
- overflow-y: hidden;
- }
- .detil {
- width: 100%;
- .box-shadow {
- box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
- padding: 20px;
- border-radius: 4px;
- border: 1px solid #e6ebf5;
- background-color: #fff;
- overflow: hidden;
- color: #303133;
- -webkit-transition: .3s;
- transition: .3s;
- margin-top: 20px;
- }
- }
- }
- </style>
|