| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- <template>
- <div>
- <d2-container>
- <!-- <template slot="header"
- ><div class="nav">当前所在位置:首页>数据字典</div></template
- > -->
- <div class="main">
- <div class="zt_right">
- <div class="nav">当前所在位置:首页>数据字典</div>
- <div class="right_main">
- <!-- <div class="right_title">
- <i
- class="fa fa-book"
- aria-hidden="true"
- style="padding-right: 5px"
- ></i
- >数据字典
- </div> -->
- <div class="right_table">
- <el-form
- :inline="true"
- :model="formInline"
- class="demo-form-inline"
- id="formLabel"
- >
- <div class="searchRow">
- <div>
- <el-form-item label="字典名称:">
- <el-input
- v-model="formInline.enumName"
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-search"
- @click="search"
- >查询</el-button
- >
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-refresh-left"
- @click="reset"
- >重置</el-button
- >
- </el-form-item>
- </div>
- <div>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-plus"
- @click="addDic()"
- >新建字典</el-button
- >
- </el-form-item>
- </div>
- </div>
- </el-form>
- <el-table
- :data="dataDictionaryList"
- border
- style="width: 100%"
- row-key="id"
- :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
- >
- <el-table-column
- prop='enumName'
- label="字典名称"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="enumCode"
- label="字典标识"
- align="center"
- >
- </el-table-column>
- <el-table-column
- prop="useState"
- label="使用状态"
- align="center"
- >
- <template slot-scope="scope">
- <div v-if="scope.row.useState==1">
- 启用
- </div>
- <div v-if="scope.row.useState==2">
- 停用
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="updateTime" label="更新时间" align="center">
- </el-table-column>
- <el-table-column align="center" label="操作" width="180">
- <template slot-scope="scope">
- <el-button
- @click="addChildren(scope.row)"
- type="text"
- size="small"
- icon="el-icon-circle-check"
- >添加子项</el-button
- >
- <el-button type="text" size="small" icon="el-icon-edit"
- @click="editChildren(scope.row,2)">修改</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <!-- <pagination
-
- :total="total"
- :page.sync="listQuery.page"
- :limit.sync="listQuery.limit"
- @pagination="getList"
- /> -->
- </div>
- </div>
- </div>
- </div>
- </d2-container>
- <!-- //字典弹框 -->
- <el-dialog :title="title" :visible.sync="dicDialog" id="dialogStyle">
- <el-form :model="form" id="dialogForm" :rules="rules" ref="formData">
- <el-form-item label="字典标识:" :label-width="formLabelWidth" prop="enumCode">
- <el-input v-model="form.enumCode" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="字典名称:" :label-width="formLabelWidth" prop="enumName">
- <el-input v-model="form.enumName" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="描述:" :label-width="formLabelWidth" prop="remark">
- <el-input v-model="form.remark" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="字典状态:" :label-width="formLabelWidth" id="switchLabel">
- <el-switch v-model="form.useState" active-text="启用"
- inactive-text="禁用"></el-switch>
- </el-form-item>
-
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dicDialog = false">取 消</el-button>
- <el-button type="primary" @click="defined('formData')">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import api from "@/api";
- // 引入分页
- import Pagination from "@/components/pagination";
- export default {
- name: "dataDictionary",
- components: { Pagination },
- data() {
- return {
- //初始化弹框标题
- title:"",
- //初始化弹框状态时关闭的
- dicDialog:false,
- //label宽度
- formLabelWidth:"120px",
- //options
- options: [
- {
- value: "zhinan",
- label: "指南",
- children: [
- {
- value: "shejiyuanze",
- label: "设计原则",
- children: [
- {
- value: "yizhi",
- label: "一致",
- },
- {
- value: "fankui",
- label: "反馈",
- },
- {
- value: "xiaolv",
- label: "效率",
- },
- {
- value: "kekong",
- label: "可控",
- },
- ],
- },
- ],
- },
- ],
- //头部查询条件
- formInline: {
- enumName:"",
- },
- //表格字段
- dataDictionaryList: [],
- btnType:null,
-
- rowId:null,
- //分页
- total: 30,
- listQuery: {
- page: 1,
- limit: 10,
- importance: undefined,
- title: undefined,
- type: undefined,
- sort: "+id",
- },
- //弹框初始化数据
- form:{
- enumCode:"",
- enumName:"",
- useState:true,
- remark:"",
- },
- //验证规则
- rules:{
- enumCode:[ {required:true,message:"请输入字典标识",trigger:"blur"}],
- enumName:[ {required:true,message:"请输入字典名称",trigger:"blur"}],
- // useState:[ {required:true,message:"请输入字典名称",trigger:"blur"}],
-
- },
- // 点确定按钮时传的id
- parentId:""
-
-
- };
- },
- methods: {
- search() {
- this.getList()
- },
- reset() {
- this.formInline.enumName="";
- this.getList()
- },
- //列表
- getList() {
- var condition = {
- enumName: this.formInline.enumName,
-
- };
- condition = JSON.stringify(condition);
- var data = {
-
- condition: condition,
- };
- api.dataDic(data).then(res=>{
- if(res.code==200){
- this.dataDictionaryList=res.data;
- }
- })
- .catch(err=>{
- console.log(err)
- })
- },
- //新增
- addDataDicList(){
-
- let data={
- enumCode:this.form.enumCode,
- enumName:this.form.enumName,
- useState:this.form.useState==true?1:2,
- remark:this.form.remark,
- parentId:this.parentId
- }
- api.addDataDic(data)
- .then(res => {
- if (res.code == 200) {
- this.$message.success("新增成功");
- this.getList();
- }
- })
- .catch(err => {
- console.log(err)
- });
-
- },
- //编辑接口
- editList() {
- var data = {
- enumCode:this.form.enumCode,
- enumName:this.form.enumName,
- useState:this.form.useState==true?1:2,
- remark:this.form.remark,
- parentId:this.parentId,
- id:this.rowId,
-
- };
- api
- .editDataDic(data)
- .then((res) => {
- if (res.code == 200) {
- this.$message.success("修改成功");
- this.getList();
- }
- })
- .catch((err) => {
- console.log(err);
- });
- },
- //查看
- handleCheck() {
- this.$router.push({
- path: "/warehouseInfo-check",
- });
- },
- //表格数的子节点加载
- load(tree, treeNode, resolve) {
- setTimeout(() => {
- resolve([
- {
- id: 11,
- branchOffice: "中储粮河南分公司",
- directLibrary: "商丘直属库",
- subTreasury: "宁陵粮油储备公司",
- cfName: "1号仓",
- keeper: "白端静",
- lxfs: "13531314569",
- lastScan: "2019-08-21 16:11:59",
- cfState: "出库",
- },
- {
- id: 12,
- branchOffice: "中储粮河南分公司",
- directLibrary: "商丘直属库",
- subTreasury: "宁陵粮油储备公司",
- cfName: "1号仓",
- keeper: "白端静",
- lxfs: "13531314569",
- lastScan: "2019-08-21 16:11:59",
- cfState: "出库",
- },
- ]);
- }, 1000);
- },
- //新建字典
- addDic(row) {
-
- this.form={}
- this.form.useState=true
- this.title = "新增字典";
- this.dicDialog = true;
- this.parentId=0;
- this.btnType=1
-
- },
- //新建子项
- addChildren(row){
-
- this.title = "新增子项";
- this.form={
- }
- this.form.useState=true
- this.dicDialog = true;
- this.parentId=row.id;
- console.log(this.form.useState,"????")
- },
- //修改子项
- editChildren(row,type) {
- console.log(row,"mmmm")
- this.btnType=type
- this.title = "修改硬件参数";
- this.parentId=row.parentId;
- this.rowId=row.id;
- this.dicDialog = true;
- this.form = JSON.parse(JSON.stringify(row));
- if(this.form.useState==1){
- this.form.useState=true;
- }else{
- this.form.useState=false;
- }
-
- },
- //点击弹框确定按钮
- defined(formData){
- console.log(this.btnType,".....")
- this.$refs[formData].validate((valid) => {
- if (valid) {
- if(this.btnType===2){
- console.log("编辑")
- this.editList();
- }else{
- console.log("新增")
- this.addDataDicList();
- }
-
- this.dicDialog = false;
- }
- });
- }
- },
- mounted(){
- this.getList();
- }
- };
- </script>
- <style lang="scss" scoped>
- .main {
- height: 100%;
- display: flex;
-
- .zt_right {
- width: 100%;
- // margin-left: 20px;
- // width: calc(100% - 250px);
- .nav {
- padding: 10px 0 10px 10px;
- // color: #fff;
- font-size: 14px;
- background: #fff;
- }
- // .right_main {
- // border: 1px solid #67a7df;
- // background: #112f5d;
- // margin-top: 10px;
- // .right_title {
- // color: #fff;
- // border-bottom: 1px solid #67a7df;
- // padding: 10px;
- // font-size: 14px;
- // }
- // .right_table {
- // padding: 20px;
- // }
- // }
- }
- }
- .searchRow {
- display: flex;
- justify-content: space-between;
- }
- // #dialogForm .el-form-item .el-form-item_label{
- // color:#000;
- // }
- </style>
|