index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-left" v-show="isShow==='home'" key="item">
  4. <div class="bill-tab">
  5. <div class="bill-title">导航</div>
  6. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  7. </div>
  8. </div>
  9. <div class="bill-main" v-show="isShow==='home'" key="item2">
  10. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  11. @resert="onRefresh" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
  12. </module-view>
  13. </div>
  14. <!-- 新增/编辑弹窗 -->
  15. <div class="detil" v-show="isShow==='add'" key="item3">
  16. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  17. <div class="box-shadow">
  18. <by-form :propConfig="addConfig" ref="addFormId">
  19. <template v-slot:k3ServerUrl="{value}" class="clearfix">
  20. <i class="el-icon-question" title="私有云必须配置金蝶云星空产品地址,K3Cloud/结尾,若为公有云则必须置空"></i>
  21. <vxe-input v-model="value.k3ServerUrl" style="width:calc(100% - 25px);margin-left: 10px;"></vxe-input>
  22. </template>
  23. <template v-slot:status class="clearfix">
  24. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">正常</el-radio>
  25. <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
  26. </template>
  27. </by-form>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script lang="ts">
  33. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  34. import api from "@/api/currency";
  35. import Assembly from "@/components/Assembly/material.vue";
  36. @Component
  37. export default class Supplier extends Vue {
  38. isShow = 'home'
  39. timeNum = 0;
  40. timer : any = null
  41. popTitle : any = ''
  42. radio : any = 0
  43. dialogFormVisible : boolean = false
  44. categoryIds : any = '';
  45. toolConfig = {
  46. tools: {
  47. return: true,
  48. save: true,
  49. }
  50. }
  51. treeConfig = {
  52. attr: {
  53. retConfig: {
  54. id: 'id',
  55. },
  56. defaultExpandAll: true,
  57. label: 'name',
  58. resType: 'data'
  59. },
  60. request: {
  61. url: '/maindata/maindataOrganizationCategory/treeUseList',
  62. method: 'GET',
  63. }
  64. }
  65. config : any = {
  66. attr: {
  67. calculateH: true
  68. },
  69. search: {
  70. attr: {
  71. size: 'mini'
  72. },
  73. columns: [
  74. [{
  75. span: 6,
  76. label: '名称',
  77. prop: 'name',
  78. component: 'by-input',
  79. labelWidth: '70px',
  80. compConfig: {
  81. attr: {
  82. placeholder: '请输入名称',
  83. clearable: true
  84. },
  85. },
  86. }, {
  87. span: 6,
  88. label: '负责人',
  89. prop: 'contacts',
  90. component: 'by-input',
  91. labelWidth: '70px',
  92. compConfig: {
  93. attr: {
  94. placeholder: '请输入负责人',
  95. clearable: true
  96. }
  97. }
  98. },
  99. {
  100. span: 6,
  101. label: '状态',
  102. prop: 'status',
  103. labelWidth: '70px',
  104. component: 'by-select',
  105. compConfig: {
  106. attr: {
  107. placeholder: '请选择状态',
  108. clearable: true,
  109. size: 'small',
  110. data: [{
  111. value: 0,
  112. label: '正常'
  113. }, {
  114. value: 1,
  115. label: '禁用'
  116. }]
  117. }
  118. }
  119. },
  120. ]
  121. ]
  122. },
  123. tool: {
  124. tools: {
  125. add: true,
  126. search: true,
  127. refresh: true
  128. }
  129. },
  130. table: {
  131. attr: {
  132. size: 'mini',
  133. align: 'left',
  134. },
  135. columns: [{
  136. title: '名称',
  137. field: 'name',
  138. isDetail: true,
  139. width: 150,
  140. },
  141. {
  142. title: '负责人',
  143. field: 'contacts',
  144. width: 120,
  145. },
  146. {
  147. title: '联系电话',
  148. field: 'phonenum',
  149. width: 150,
  150. },
  151. {
  152. title: '手机号码',
  153. field: 'telephone',
  154. width: 150,
  155. },
  156. {
  157. width: 300,
  158. title: '财务系统类型',
  159. field: 'financeType2',
  160. },
  161. {
  162. width: 80,
  163. title: '状态',
  164. field: 'status',
  165. component: Assembly,
  166. }, {
  167. width: 120,
  168. title: '操作',
  169. action: true,
  170. plugins: [{
  171. icon: 'el-icon-edit',
  172. name: '编辑',
  173. audit: '',
  174. event: {
  175. click: (item : any) => {
  176. (this as any).openEdit(item)
  177. }
  178. }
  179. }, {
  180. name: '删除',
  181. event: {
  182. click: (item : any) => (this as any).doDelete(item)
  183. }
  184. }]
  185. }]
  186. },
  187. }
  188. addConfig = {
  189. attr: {
  190. size: 'medium',
  191. rules: {
  192. categoryName: [{
  193. required: true, message: '请输入父级', trigger: 'change'
  194. }],
  195. name: [{
  196. required: true, message: '请输入名称', trigger: 'blur'
  197. }],
  198. contacts: [{
  199. required: true, message: '请输入负责人', trigger: 'blur'
  200. }],
  201. financeType: [{
  202. required: true, message: '请输入财务系统类型', trigger: 'change'
  203. }],
  204. }
  205. },
  206. columns: [
  207. [
  208. {
  209. span: 6,
  210. label: '父级',
  211. prop: 'categoryName',
  212. component: 'select-tree',
  213. compConfig: {
  214. attr: {
  215. label: 'name',
  216. clearable: true,
  217. retConfig: {
  218. categoryId: 'id',
  219. categoryName: 'name',
  220. },
  221. defaultExpandAll: true
  222. },
  223. request: {
  224. url: '/maindata/maindataOrganizationCategory/treeUseList'
  225. }
  226. }
  227. },
  228. {
  229. span: 6,
  230. label: '名称',
  231. prop: 'name',
  232. component: 'by-input',
  233. },
  234. {
  235. span: 6,
  236. label: '负责人',
  237. prop: 'contacts',
  238. component: 'by-input',
  239. },
  240. {
  241. span: 6,
  242. label: '手机号码',
  243. prop: 'telephone',
  244. component: 'by-input',
  245. },
  246. {
  247. span: 6,
  248. label: '联系电话',
  249. prop: 'phonenum',
  250. component: 'by-input',
  251. },
  252. ],
  253. [
  254. {
  255. span: 6,
  256. labelWidth: '110px',
  257. label: '财务系统类型',
  258. prop: 'financeType',
  259. component: 'by-select',
  260. compConfig: {
  261. attr: {
  262. placeholder: '请选择财务系统类型',
  263. clearable: true,
  264. size: 'small',
  265. data: [
  266. {
  267. value: 'kingdee',
  268. label: '金蝶K3'
  269. },
  270. // {
  271. // value: 'yonbip',
  272. // label: '用友U8'
  273. // },
  274. ]
  275. }
  276. }
  277. },
  278. ],
  279. [
  280. {
  281. span: 6,
  282. label: '登录授权ID',
  283. slot: true,
  284. prop: 'k3AppId',
  285. component: 'by-input',
  286. },
  287. {
  288. span: 6,
  289. label: '用户名称',
  290. slot: true,
  291. prop: 'k3UserName',
  292. component: 'by-input',
  293. },
  294. {
  295. span: 6,
  296. label: '数据中心ID',
  297. slot: true,
  298. prop: 'k3AcctId',
  299. component: 'by-input',
  300. },
  301. {
  302. span: 6,
  303. label: '应用秘钥',
  304. slot: true,
  305. prop: 'k3AppSec',
  306. component: 'by-input',
  307. },
  308. {
  309. span: 6,
  310. label: 'URL地址',
  311. slot: true,
  312. prop: 'k3ServerUrl',
  313. },
  314. ],
  315. [
  316. {
  317. span: 6,
  318. label: '状态',
  319. slot: true,
  320. prop: 'status',
  321. },
  322. ]
  323. ]
  324. }
  325. mounted() {
  326. this.timer = setInterval(() => {
  327. this.getDataList()
  328. }, 300)
  329. }
  330. //点击树获取数据
  331. onChangeTree(e : any) {
  332. this.categoryIds = e.id;
  333. let loading = this.$loading({ target: '.main-container' });
  334. api.byCategoryPage({ categoryId: e.id, type: 1 }, 'maindataOrganizationCategory').then((res : any) => {
  335. if (res.code === 200) {
  336. (this.$refs.moduleView as any).setTableValue(res.data.records);
  337. let page = {
  338. pageNo: res.data.current, //当前页
  339. pageSize: res.data.size, //每页条数
  340. total: res.data.total //总条数
  341. };
  342. (this.$refs.moduleView as any).setPage(page);
  343. loading.close();
  344. } else loading.close();
  345. }).catch(() => loading.close());
  346. }
  347. // 内页工具栏方法
  348. insideTools(e : any) {
  349. console.log(e);
  350. if (e === 'onReturn') this.isShow = 'home';
  351. if (e === 'onSave') this.confirm();
  352. }
  353. // 保存新增/编辑
  354. confirm() {
  355. (this as any).$refs.addFormId.validate().then(() => {
  356. let query = (this as any).$refs.addFormId.getValue();
  357. query.status = this.radio;
  358. // 手机验证
  359. let reg = /^1[3456789]\d{9}$/;
  360. let reg2 = /^0\d{2,3}-\d{7,8}$/;
  361. if (query.telephone && !reg.test(query.telephone)) return this.$message.warning('请输入正确手机号码');
  362. if (query.phonenum && !reg2.test(query.phonenum)) return this.$message.warning('请输入正确联系电话');
  363. if (!query.telephone) query.telephone = null;
  364. if (!query.phonenum) query.phonenum = null;
  365. this.dialogFormVisible = false;
  366. console.log(query);
  367. let loading = this.$loading({ target: '.main-container' });
  368. if (this.popTitle === '新增') {
  369. api.saveList(query, 'maindataMaterialSupplier').then((res : any) => {
  370. loading.close();
  371. if (res.code === 200) {
  372. this.$message.success('保存成功');
  373. (this as any).$refs.sideTree.request();
  374. this.isShow = 'home'; // 展示类型
  375. this.getDataList();
  376. } else this.$message.error(res.msg);
  377. }).catch(() => loading.close());
  378. } else if (this.popTitle === '编辑') {
  379. api.updateList(query, 'maindataMaterialSupplier').then((res : any) => {
  380. loading.close();
  381. if (res.code === 200) {
  382. this.$message.success('编辑成功');
  383. (this as any).$refs.sideTree.request();
  384. this.isShow = 'home'; // 展示类型
  385. this.getDataList();
  386. } else this.$message.error(res.msg);
  387. }).catch(() => loading.close());
  388. }
  389. })
  390. }
  391. // 获取列表数据
  392. getDataList() {
  393. if (!this.$refs.moduleView) {
  394. if (this.timeNum > 5) {
  395. clearInterval(this.timer)
  396. }
  397. this.timeNum++;
  398. return
  399. }
  400. clearInterval(this.timer)
  401. let query = (this.$refs.moduleView as any).getQuery();
  402. if (this.categoryIds) query.categoryIds = this.categoryIds;
  403. console.log('表单字段 ==> ', query);
  404. this.getPageList(query)
  405. }
  406. getPageList(query : any) {
  407. let loading = this.$loading({ target: '.main-container' });
  408. api.pageList(query, 'maindataMaterialSupplier').then((res : any) => {
  409. loading.close();
  410. if (res.code === 200) {
  411. res.data.records.map((v : any) => {
  412. if (v.financeType === 'kingdee') v.financeType2 = '金蝶K3';
  413. if (v.financeType === 'yonbip') v.financeType2 = '用友U8';
  414. });
  415. (this.$refs.moduleView as any).setTableValue(res.data.records);
  416. let page = {
  417. pageNo: res.data.current, //当前页
  418. pageSize: res.data.size, //每页条数
  419. total: res.data.total //总条数
  420. };
  421. (this.$refs.moduleView as any).setPage(page);
  422. } else this.$message.error(res.msg);
  423. }).catch(() => loading.close());
  424. }
  425. // 工具栏方法
  426. clickHandle(e : any) {
  427. if (e === 'onAdd') this.onAdd();
  428. }
  429. // 打开新增
  430. onAdd() {
  431. this.isShow = 'add'; // 展示类型
  432. this.popTitle = '新增'
  433. this.dialogFormVisible = true;
  434. this.radio = 0
  435. this.$nextTick(() => (this as any).$refs.addFormId.setValue());
  436. }
  437. // 打开编辑
  438. openEdit(e : any) {
  439. console.log('打开编辑 ==> ', e);
  440. this.isShow = 'add'; // 展示类型
  441. this.popTitle = '编辑'
  442. let loading = this.$loading({ target: '.main-container' });
  443. api.single({ id: e.id }, 'maindataMaterialSupplier').then((res : any) => {
  444. if (res.code === 200) {
  445. let data = res.data;
  446. this.radio = data.status;
  447. this.dialogFormVisible = true;
  448. this.$nextTick(() => (this as any).$refs.addFormId.setValue(data));
  449. loading.close();
  450. } else loading.close();
  451. }).catch(() => loading.close());
  452. }
  453. // 操作删除
  454. doDelete(item : any) {
  455. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  456. confirmButtonText: '确定',
  457. cancelButtonText: '取消',
  458. type: 'warning',
  459. center: true
  460. }).then(() => {
  461. let loading = this.$loading({ target: '.main-container' });
  462. api.deleteList({ ids: item.id }, 'maindataMaterialSupplier').then((res : any) => {
  463. loading.close();
  464. if (res.code === 200) {
  465. (this as any).$refs.sideTree.request();
  466. this.getDataList();
  467. this.$message.success('删除成功');
  468. } else this.$message.error(res.msg);
  469. }).catch(() => loading.close());
  470. }).catch(() => this.$message.info('已取消删除'));
  471. }
  472. // 刷新/重置
  473. onRefresh() {
  474. (this as any).$refs.moduleView.clearSearch();
  475. (this as any).$refs.sideTree.request();
  476. this.categoryIds = '';
  477. this.getDataList();
  478. }
  479. }
  480. </script>
  481. <style lang="scss" scoped>
  482. .my-container {
  483. width: 100%;
  484. box-sizing: border-box;
  485. display: flex;
  486. padding: 16px;
  487. height: 100%;
  488. .bill-left {
  489. position: relative;
  490. border-right: solid #EEE 1px;
  491. padding-right: 16px;
  492. flex-shrink: 0;
  493. .bill-tab {
  494. width: 150px;
  495. height: 100%;
  496. transition: all .5s;
  497. overflow: hidden;
  498. }
  499. .tab-title {
  500. font-size: 16px;
  501. padding-bottom: 16px;
  502. width: 200px;
  503. }
  504. }
  505. .bill-main {
  506. width: calc(100% - 16px);
  507. box-sizing: border-box;
  508. margin-left: 16px;
  509. position: relative;
  510. height: 100%;
  511. overflow-y: hidden;
  512. }
  513. .detil {
  514. width: 100%;
  515. .box-shadow {
  516. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  517. padding: 20px;
  518. border-radius: 4px;
  519. border: 1px solid #e6ebf5;
  520. background-color: #fff;
  521. overflow: hidden;
  522. color: #303133;
  523. -webkit-transition: .3s;
  524. transition: .3s;
  525. margin-top: 20px;
  526. }
  527. }
  528. }
  529. </style>