index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <div>
  3. <d2-container>
  4. <!-- <template slot="header"
  5. ><div class="nav">当前所在位置:首页>数据字典</div></template
  6. > -->
  7. <div class="main">
  8. <div class="zt_right">
  9. <div class="nav">当前所在位置:首页>数据字典</div>
  10. <div class="right_main">
  11. <!-- <div class="right_title">
  12. <i
  13. class="fa fa-book"
  14. aria-hidden="true"
  15. style="padding-right: 5px"
  16. ></i
  17. >数据字典
  18. </div> -->
  19. <div class="right_table">
  20. <el-form
  21. :inline="true"
  22. :model="formInline"
  23. class="demo-form-inline"
  24. id="formLabel"
  25. >
  26. <div class="searchRow">
  27. <div>
  28. <el-form-item label="字典名称:">
  29. <el-input
  30. v-model="formInline.enumName"
  31. placeholder="请输入"
  32. ></el-input>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button
  36. type="primary"
  37. icon="el-icon-search"
  38. @click="search"
  39. >查询</el-button
  40. >
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button
  44. type="primary"
  45. icon="el-icon-refresh-left"
  46. @click="reset"
  47. >重置</el-button
  48. >
  49. </el-form-item>
  50. </div>
  51. <div>
  52. <el-form-item>
  53. <el-button
  54. type="primary"
  55. icon="el-icon-plus"
  56. @click="addDic()"
  57. >新建字典</el-button
  58. >
  59. </el-form-item>
  60. </div>
  61. </div>
  62. </el-form>
  63. <el-table
  64. :data="dataDictionaryList"
  65. border
  66. style="width: 100%"
  67. row-key="id"
  68. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  69. >
  70. <el-table-column
  71. prop='enumName'
  72. label="字典名称"
  73. align="center"
  74. >
  75. </el-table-column>
  76. <el-table-column
  77. prop="enumCode"
  78. label="字典标识"
  79. align="center"
  80. >
  81. </el-table-column>
  82. <el-table-column
  83. prop="useState"
  84. label="使用状态"
  85. align="center"
  86. >
  87. <template slot-scope="scope">
  88. <div v-if="scope.row.useState==1">
  89. 启用
  90. </div>
  91. <div v-if="scope.row.useState==2">
  92. 停用
  93. </div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column prop="updateTime" label="更新时间" align="center">
  97. </el-table-column>
  98. <el-table-column align="center" label="操作" width="180">
  99. <template slot-scope="scope">
  100. <el-button
  101. @click="addChildren(scope.row)"
  102. type="text"
  103. size="small"
  104. icon="el-icon-circle-check"
  105. >添加子项</el-button
  106. >
  107. <el-button type="text" size="small" icon="el-icon-edit"
  108. @click="editChildren(scope.row,2)">修改</el-button
  109. >
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <!-- <pagination
  114. :total="total"
  115. :page.sync="listQuery.page"
  116. :limit.sync="listQuery.limit"
  117. @pagination="getList"
  118. /> -->
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </d2-container>
  124. <!-- //字典弹框 -->
  125. <el-dialog :title="title" :visible.sync="dicDialog" id="dialogStyle">
  126. <el-form :model="form" id="dialogForm" :rules="rules" ref="formData">
  127. <el-form-item label="字典标识:" :label-width="formLabelWidth" prop="enumCode">
  128. <el-input v-model="form.enumCode" autocomplete="off"></el-input>
  129. </el-form-item>
  130. <el-form-item label="字典名称:" :label-width="formLabelWidth" prop="enumName">
  131. <el-input v-model="form.enumName" autocomplete="off"></el-input>
  132. </el-form-item>
  133. <el-form-item label="描述:" :label-width="formLabelWidth" prop="remark">
  134. <el-input v-model="form.remark" autocomplete="off"></el-input>
  135. </el-form-item>
  136. <el-form-item label="字典状态:" :label-width="formLabelWidth" id="switchLabel">
  137. <el-switch v-model="form.useState" active-text="启用"
  138. inactive-text="禁用"></el-switch>
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button @click="dicDialog = false">取 消</el-button>
  143. <el-button type="primary" @click="defined('formData')">确 定</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import api from "@/api";
  150. // 引入分页
  151. import Pagination from "@/components/pagination";
  152. export default {
  153. name: "dataDictionary",
  154. components: { Pagination },
  155. data() {
  156. return {
  157. //初始化弹框标题
  158. title:"",
  159. //初始化弹框状态时关闭的
  160. dicDialog:false,
  161. //label宽度
  162. formLabelWidth:"120px",
  163. //options
  164. options: [
  165. {
  166. value: "zhinan",
  167. label: "指南",
  168. children: [
  169. {
  170. value: "shejiyuanze",
  171. label: "设计原则",
  172. children: [
  173. {
  174. value: "yizhi",
  175. label: "一致",
  176. },
  177. {
  178. value: "fankui",
  179. label: "反馈",
  180. },
  181. {
  182. value: "xiaolv",
  183. label: "效率",
  184. },
  185. {
  186. value: "kekong",
  187. label: "可控",
  188. },
  189. ],
  190. },
  191. ],
  192. },
  193. ],
  194. //头部查询条件
  195. formInline: {
  196. enumName:"",
  197. },
  198. //表格字段
  199. dataDictionaryList: [],
  200. btnType:null,
  201. rowId:null,
  202. //分页
  203. total: 30,
  204. listQuery: {
  205. page: 1,
  206. limit: 10,
  207. importance: undefined,
  208. title: undefined,
  209. type: undefined,
  210. sort: "+id",
  211. },
  212. //弹框初始化数据
  213. form:{
  214. enumCode:"",
  215. enumName:"",
  216. useState:true,
  217. remark:"",
  218. },
  219. //验证规则
  220. rules:{
  221. enumCode:[ {required:true,message:"请输入字典标识",trigger:"blur"}],
  222. enumName:[ {required:true,message:"请输入字典名称",trigger:"blur"}],
  223. // useState:[ {required:true,message:"请输入字典名称",trigger:"blur"}],
  224. },
  225. // 点确定按钮时传的id
  226. parentId:""
  227. };
  228. },
  229. methods: {
  230. search() {
  231. this.getList()
  232. },
  233. reset() {
  234. this.formInline.enumName="";
  235. this.getList()
  236. },
  237. //列表
  238. getList() {
  239. var condition = {
  240. enumName: this.formInline.enumName,
  241. };
  242. condition = JSON.stringify(condition);
  243. var data = {
  244. condition: condition,
  245. };
  246. api.dataDic(data).then(res=>{
  247. if(res.code==200){
  248. this.dataDictionaryList=res.data;
  249. }
  250. })
  251. .catch(err=>{
  252. console.log(err)
  253. })
  254. },
  255. //新增
  256. addDataDicList(){
  257. let data={
  258. enumCode:this.form.enumCode,
  259. enumName:this.form.enumName,
  260. useState:this.form.useState==true?1:2,
  261. remark:this.form.remark,
  262. parentId:this.parentId
  263. }
  264. api.addDataDic(data)
  265. .then(res => {
  266. if (res.code == 200) {
  267. this.$message.success("新增成功");
  268. this.getList();
  269. }
  270. })
  271. .catch(err => {
  272. console.log(err)
  273. });
  274. },
  275. //编辑接口
  276. editList() {
  277. var data = {
  278. enumCode:this.form.enumCode,
  279. enumName:this.form.enumName,
  280. useState:this.form.useState==true?1:2,
  281. remark:this.form.remark,
  282. parentId:this.parentId,
  283. id:this.rowId,
  284. };
  285. api
  286. .editDataDic(data)
  287. .then((res) => {
  288. if (res.code == 200) {
  289. this.$message.success("修改成功");
  290. this.getList();
  291. }
  292. })
  293. .catch((err) => {
  294. console.log(err);
  295. });
  296. },
  297. //查看
  298. handleCheck() {
  299. this.$router.push({
  300. path: "/warehouseInfo-check",
  301. });
  302. },
  303. //表格数的子节点加载
  304. load(tree, treeNode, resolve) {
  305. setTimeout(() => {
  306. resolve([
  307. {
  308. id: 11,
  309. branchOffice: "中储粮河南分公司",
  310. directLibrary: "商丘直属库",
  311. subTreasury: "宁陵粮油储备公司",
  312. cfName: "1号仓",
  313. keeper: "白端静",
  314. lxfs: "13531314569",
  315. lastScan: "2019-08-21 16:11:59",
  316. cfState: "出库",
  317. },
  318. {
  319. id: 12,
  320. branchOffice: "中储粮河南分公司",
  321. directLibrary: "商丘直属库",
  322. subTreasury: "宁陵粮油储备公司",
  323. cfName: "1号仓",
  324. keeper: "白端静",
  325. lxfs: "13531314569",
  326. lastScan: "2019-08-21 16:11:59",
  327. cfState: "出库",
  328. },
  329. ]);
  330. }, 1000);
  331. },
  332. //新建字典
  333. addDic(row) {
  334. this.form={}
  335. this.form.useState=true
  336. this.title = "新增字典";
  337. this.dicDialog = true;
  338. this.parentId=0;
  339. this.btnType=1
  340. },
  341. //新建子项
  342. addChildren(row){
  343. this.title = "新增子项";
  344. this.form={
  345. }
  346. this.form.useState=true
  347. this.dicDialog = true;
  348. this.parentId=row.id;
  349. console.log(this.form.useState,"????")
  350. },
  351. //修改子项
  352. editChildren(row,type) {
  353. console.log(row,"mmmm")
  354. this.btnType=type
  355. this.title = "修改硬件参数";
  356. this.parentId=row.parentId;
  357. this.rowId=row.id;
  358. this.dicDialog = true;
  359. this.form = JSON.parse(JSON.stringify(row));
  360. if(this.form.useState==1){
  361. this.form.useState=true;
  362. }else{
  363. this.form.useState=false;
  364. }
  365. },
  366. //点击弹框确定按钮
  367. defined(formData){
  368. console.log(this.btnType,".....")
  369. this.$refs[formData].validate((valid) => {
  370. if (valid) {
  371. if(this.btnType===2){
  372. console.log("编辑")
  373. this.editList();
  374. }else{
  375. console.log("新增")
  376. this.addDataDicList();
  377. }
  378. this.dicDialog = false;
  379. }
  380. });
  381. }
  382. },
  383. mounted(){
  384. this.getList();
  385. }
  386. };
  387. </script>
  388. <style lang="scss" scoped>
  389. .main {
  390. height: 100%;
  391. display: flex;
  392. .zt_right {
  393. width: 100%;
  394. // margin-left: 20px;
  395. // width: calc(100% - 250px);
  396. .nav {
  397. padding: 10px 0 10px 10px;
  398. // color: #fff;
  399. font-size: 14px;
  400. background: #fff;
  401. }
  402. // .right_main {
  403. // border: 1px solid #67a7df;
  404. // background: #112f5d;
  405. // margin-top: 10px;
  406. // .right_title {
  407. // color: #fff;
  408. // border-bottom: 1px solid #67a7df;
  409. // padding: 10px;
  410. // font-size: 14px;
  411. // }
  412. // .right_table {
  413. // padding: 20px;
  414. // }
  415. // }
  416. }
  417. }
  418. .searchRow {
  419. display: flex;
  420. justify-content: space-between;
  421. }
  422. // #dialogForm .el-form-item .el-form-item_label{
  423. // color:#000;
  424. // }
  425. </style>