index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div class="my-container">
  3. <transition name="el-zoom-in-center">
  4. <div class="bill-main" key="index">
  5. <module-view :propConfig="config" v-show="isShow==='home'" ref="moduleView" @pagination="getDataList"
  6. @search="getDataList" @resert="onRefresh" @detail="openEdit" @onRefresh="onRefresh">
  7. </module-view>
  8. </div>
  9. </transition>
  10. <!-- 新增/编辑弹窗 -->
  11. <transition name="el-zoom-in-center">
  12. <div class="detil" v-show="isShow==='add'" key="index2">
  13. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  14. <div class="box-shadow">
  15. <by-table :propConfig="skuConfig" ref="addFormId"></by-table>
  16. </div>
  17. </div>
  18. </transition>
  19. </div>
  20. </template>
  21. <script lang="ts">
  22. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  23. import api from "@/api/currency";
  24. import ForTab from "@/components/ForTab/index.vue";
  25. @Component({ components: { ForTab } })
  26. export default class Attribute extends Vue {
  27. // 右边
  28. isShow : any = 'home'
  29. timeNum = 0;
  30. calculateCount = 0;
  31. timer : any = null
  32. toolConfig = {
  33. tools: {
  34. return: true,
  35. save: true,
  36. },
  37. customTools: [
  38. // {
  39. // name: '同步到财务系统', icon: 'el-icon-top', audit: [''], event: {
  40. // click: () => {
  41. // (this as any).syncSystem()
  42. // }
  43. // }
  44. // },
  45. ]
  46. }
  47. skuConfig : any = {
  48. attr: {
  49. size: 'mini',
  50. align: 'left',
  51. },
  52. columns: [
  53. {
  54. width: '150px',
  55. title: '标题',
  56. field: 'skuTitle',
  57. },
  58. {
  59. width: '120px',
  60. title: '副标题',
  61. field: 'skuSubtitle',
  62. },
  63. {
  64. width: '140px',
  65. title: '物料编码',
  66. field: 'skuCode',
  67. },
  68. {
  69. width: '140px',
  70. title: '财务编号',
  71. field: 'financialCode',
  72. component: 'by-input',
  73. compConfig: {
  74. attr: {
  75. size: 'mini',
  76. placeholder: ' '
  77. },
  78. }
  79. },
  80. {
  81. width: '90px',
  82. title: '价格',
  83. field: 'price',
  84. compConfig: {
  85. attr: {
  86. size: 'mini',
  87. placeholder: ' ',
  88. type: "number",
  89. defaultValue: 0
  90. },
  91. }
  92. },
  93. {
  94. width: '90px',
  95. title: '单位',
  96. field: 'unit',
  97. compConfig: {
  98. attr: {
  99. size: 'mini',
  100. placeholder: ' ',
  101. },
  102. }
  103. },
  104. {
  105. width: '90px',
  106. title: '单位编码',
  107. field: 'unitCode',
  108. compConfig: {
  109. attr: {
  110. size: 'mini',
  111. placeholder: ' ',
  112. },
  113. }
  114. },
  115. {
  116. width: '110px',
  117. title: '保质期(天)',
  118. field: 'shelfLife',
  119. compConfig: {
  120. attr: {
  121. size: 'mini',
  122. placeholder: ' ',
  123. type: "integer",
  124. },
  125. }
  126. },
  127. {
  128. width: '90px',
  129. title: '重量/g',
  130. field: 'weight',
  131. compConfig: {
  132. attr: {
  133. size: 'mini',
  134. placeholder: ' ',
  135. type: "number",
  136. },
  137. }
  138. },
  139. {
  140. width: '90px',
  141. title: '长/cm',
  142. field: 'length',
  143. compConfig: {
  144. attr: {
  145. size: 'mini',
  146. placeholder: ' ',
  147. type: "number",
  148. },
  149. }
  150. },
  151. {
  152. width: '90px',
  153. title: '宽/cm',
  154. field: 'width',
  155. compConfig: {
  156. attr: {
  157. size: 'mini',
  158. placeholder: ' ',
  159. type: "number",
  160. },
  161. }
  162. },
  163. {
  164. width: '90px',
  165. title: '高/cm',
  166. field: 'height',
  167. compConfig: {
  168. attr: {
  169. size: 'mini',
  170. placeholder: ' ',
  171. type: "number",
  172. },
  173. }
  174. },
  175. {
  176. width: '90px',
  177. title: '体积/cm³',
  178. field: 'volume',
  179. },
  180. ]
  181. }
  182. config : any = {
  183. search: {
  184. attr: {
  185. size: 'mini'
  186. },
  187. columns: [
  188. [
  189. {
  190. span: 6,
  191. label: '物料编码',
  192. prop: 'skuCode',
  193. component: 'by-input',
  194. labelWidth: '70px',
  195. compConfig: {
  196. attr: {
  197. placeholder: '请输入物料编码',
  198. clearable: true
  199. }
  200. }
  201. },
  202. {
  203. span: 6,
  204. label: '财务编号',
  205. prop: 'financialCode',
  206. component: 'by-input',
  207. compConfig: {
  208. attr: {
  209. placeholder: '请输入财务编号',
  210. clearable: true
  211. }
  212. }
  213. },
  214. ],
  215. ]
  216. },
  217. tool: {
  218. tools: {
  219. search: true,
  220. refresh: true,
  221. },
  222. // customTools: [
  223. // {
  224. // name: '同步到财务系统', icon: 'el-icon-top', audit: [''], event: {
  225. // click: () => {
  226. // (this as any).syncSystem()
  227. // }
  228. // }
  229. // },
  230. // ]
  231. },
  232. table: {
  233. attr: {
  234. size: 'mini',
  235. align: 'left',
  236. height: '620'
  237. },
  238. columns: [
  239. {
  240. width: '200px',
  241. title: '标题',
  242. field: 'skuTitle',
  243. isDetail: true
  244. },
  245. {
  246. width: '200px',
  247. title: '副标题',
  248. field: 'skuSubtitle',
  249. },
  250. {
  251. width: '140px',
  252. title: '物料编码',
  253. field: 'skuCode',
  254. },
  255. {
  256. width: '140px',
  257. title: '财务编号',
  258. field: 'financialCode',
  259. },
  260. {
  261. width: '80px',
  262. title: '价格',
  263. field: 'price',
  264. },
  265. {
  266. width: '80px',
  267. title: '单位',
  268. field: 'unit',
  269. },
  270. {
  271. width: '80px',
  272. title: '单位编码',
  273. field: 'unitCode',
  274. },
  275. {
  276. width: '100px',
  277. title: '保质期(天)',
  278. field: 'shelfLife',
  279. },
  280. {
  281. width: '80px',
  282. title: '重量/g',
  283. field: 'weight',
  284. },
  285. {
  286. width: '80px',
  287. title: '长/cm',
  288. field: 'length',
  289. },
  290. {
  291. width: '80px',
  292. title: '宽/cm',
  293. field: 'width',
  294. },
  295. {
  296. width: '80px',
  297. title: '高/cm',
  298. field: 'height',
  299. },
  300. {
  301. width: '90px',
  302. title: '体积/cm³',
  303. field: 'volume',
  304. },
  305. {
  306. width: 70,
  307. title: '操作',
  308. action: true,
  309. plugins: [{
  310. icon: 'el-icon-edit',
  311. name: '编辑',
  312. audit: '',
  313. event: {
  314. click: (item : any) => {
  315. (this as any).openEdit(item)
  316. }
  317. }
  318. }]
  319. }]
  320. },
  321. }
  322. mounted() {
  323. this.timer = setInterval(() => {
  324. this.getDataList();
  325. this.initTable();
  326. }, 300)
  327. }
  328. // 计算高度
  329. initTable() {
  330. if (!this.$refs.moduleView) {
  331. this.calculateCount++;
  332. if (this.calculateCount > 5) return;
  333. setTimeout(() => {
  334. this.initTable()
  335. }, 500)
  336. return
  337. }
  338. let tableId : any = (this as any).$refs.moduleView.tableID;
  339. this.config.table.attr.height = window.innerHeight - 300;
  340. (this as any).$refs.moduleView.$refs[tableId].recalculate();
  341. }
  342. // 保存
  343. doFormData() {
  344. let data : any = (this as any).$refs.addFormId.getValue()
  345. if (!data[0].financialCode) return this.$message.warning('财务编号不能为空');
  346. api.updateList(data[0], 'maindataMaterialSku').then((res : any) => {
  347. if (res.code === 200) {
  348. this.$message.success('编辑成功');
  349. this.isShow = 'home';
  350. this.getDataList();
  351. } else this.$message.error(res.msg);
  352. })
  353. }
  354. // 获取列表数据
  355. getDataList() {
  356. if (!this.$refs.moduleView) {
  357. if (this.timeNum > 5) {
  358. clearInterval(this.timer)
  359. }
  360. this.timeNum++;
  361. return
  362. }
  363. clearInterval(this.timer)
  364. let query = (this.$refs.moduleView as any).getQuery();
  365. // console.log('表单字段 ==> ', query);
  366. this.getPageList(query)
  367. }
  368. getPageList(query : any) {
  369. let loading = this.$loading({ target: '.main-container' });
  370. api.pageList(query, 'maindataMaterialSku').then((res : any) => {
  371. loading.close();
  372. if (res.code === 200) {
  373. (this.$refs.moduleView as any).setTableValue(res.data.records);
  374. let page = {
  375. pageNo: res.data.current, //当前页
  376. pageSize: res.data.size, //每页条数
  377. total: res.data.total //总条数
  378. };
  379. (this.$refs.moduleView as any).setPage(page);
  380. } else this.$message.error(res.msg);
  381. }).catch(() => loading.close());
  382. }
  383. // 打开编辑
  384. openEdit(e : any) {
  385. let loading = this.$loading({ target: '.main-container' });
  386. api.single({ id: e.id }, 'maindataMaterialSku').then((res : any) => {
  387. loading.close();
  388. if (res.code === 200) {
  389. this.isShow = 'add';
  390. setTimeout(() => { (this as any).$refs.addFormId.setValue([res.data]) }, 0);
  391. } else loading.close();
  392. }).catch(() => loading.close());
  393. }
  394. // 内页工具栏方法
  395. insideTools(e : any) {
  396. if (e === 'onReturn') this.isShow = 'home';
  397. if (e === 'onSave') this.doFormData();
  398. }
  399. // 刷新/重置
  400. onRefresh() {
  401. (this as any).$refs.moduleView.clearSearch();
  402. this.getDataList();
  403. }
  404. }
  405. </script>
  406. <style lang="scss" scoped>
  407. .my-container {
  408. width: 100%;
  409. box-sizing: border-box;
  410. display: flex;
  411. height: 100%;
  412. .bill-left {
  413. position: relative;
  414. border-right: solid #EEE 1px;
  415. padding-right: 16px;
  416. flex-shrink: 0;
  417. .bill-tab {
  418. width: 150px;
  419. height: 100%;
  420. transition: all .5s;
  421. overflow: hidden;
  422. }
  423. .tab-title {
  424. font-size: 16px;
  425. padding-bottom: 16px;
  426. width: 200px;
  427. }
  428. }
  429. .bill-main {
  430. width: calc(100% - 16px);
  431. box-sizing: border-box;
  432. margin-left: 16px;
  433. position: relative;
  434. }
  435. .detil {
  436. width: 100%;
  437. .box-shadow {
  438. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  439. padding: 20px;
  440. border-radius: 4px;
  441. border: 1px solid #e6ebf5;
  442. background-color: #fff;
  443. overflow: hidden;
  444. color: #303133;
  445. -webkit-transition: .3s;
  446. transition: .3s;
  447. margin-top: 20px;
  448. }
  449. }
  450. @media screen and (min-width: 1700px) {
  451. .bill-main {
  452. min-width: 1450px;
  453. }
  454. }
  455. }
  456. </style>