index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <div>
  3. <basic-container
  4. v-show="isShow">
  5. <avue-crud :option="option"
  6. :data="dataList"
  7. ref="crud"
  8. v-model="form"
  9. :page.sync="page"
  10. @row-del="rowDel"
  11. @row-update="rowUpdate"
  12. :before-open="beforeOpen"
  13. :before-close="beforeClose"
  14. :search.sync="search"
  15. @row-save="rowSave"
  16. @saveColumn="saveColumn"
  17. @search-change="searchChange"
  18. @search-reset="searchReset"
  19. @selection-change="selectionChange"
  20. @current-change="currentChange"
  21. @size-change="sizeChange"
  22. @refresh-change="refreshChange"
  23. @on-load="onLoad"
  24. @tree-load="treeLoad"
  25. :cell-style="tableRowClassName"
  26. :table-loading="loading"
  27. @expand-change="expandChange"
  28. @resetColumn="resetColumn"
  29. >
  30. <template slot-scope="scope" slot="expand">
  31. <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
  32. <el-table-column label="产品分类" prop="priceCategory" align="center" show-overflow-tooltip width="200"></el-table-column>
  33. <el-table-column label="价格类别" prop="priceType" align="center" show-overflow-tooltip width="180"></el-table-column>
  34. <el-table-column label="商品名称" prop="cname" align="center" show-overflow-tooltip width="120"></el-table-column>
  35. <el-table-column label="编码" prop="code" align="center" show-overflow-tooltip width="120"></el-table-column>
  36. <el-table-column label="规格型号" prop="typeno" align="center" show-overflow-tooltip width="120"></el-table-column>
  37. <el-table-column label="供应商" prop="corpName" align="center" show-overflow-tooltip width="120"></el-table-column>
  38. <el-table-column label="订货数量" prop="orderQuantity" align="center" show-overflow-tooltip width="180"></el-table-column>
  39. <el-table-column label="发货数量" prop="actualQuantity" align="center" show-overflow-tooltip width="200"></el-table-column>
  40. <el-table-column label="库存" prop="storageQuantity" align="center" show-overflow-tooltip width="200"></el-table-column>
  41. <el-table-column label="采购价格" prop="purchaseAmount" align="center" show-overflow-tooltip width="200"></el-table-column>
  42. <el-table-column label="最新单价" prop="price" align="center" show-overflow-tooltip width="200"></el-table-column>
  43. <el-table-column label="金额" prop="amount" align="center" show-overflow-tooltip width="200"></el-table-column>
  44. </el-table>
  45. </template>
  46. <template slot-scope="scope" slot="orderNo">
  47. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.orgOrderNo }}</span>
  48. </template>
  49. <template slot="corpIdSearch">
  50. <crop-select
  51. v-model="search.corpId"
  52. corpType="KH"
  53. ></crop-select>
  54. </template>
  55. <template slot-scope="scope" slot="corpId">
  56. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.corpsName }}</span>
  57. </template>
  58. <template slot-scope="scope" slot="createUser">
  59. {{ scope.row.createUserName }}
  60. </template>
  61. <template slot="menuLeft" slot-scope="{size}">
  62. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制单据</el-button>
  63. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  64. </template>
  65. <template slot-scope="scope" slot="menu">
  66. <!-- <el-button-->
  67. <!-- type="text"-->
  68. <!-- icon="el-icon-edit"-->
  69. <!-- size="small"-->
  70. <!-- @click.stop="editOpen(scope.row,scope.index)"-->
  71. <!-- >编辑-->
  72. <!-- </el-button>-->
  73. <el-button
  74. type="text"
  75. icon="el-icon-delete"
  76. size="small"
  77. @click.stop="rowDel(scope.row,scope.index)"
  78. :disabled="scope.row.status > 0"
  79. >删除
  80. </el-button>
  81. </template>
  82. </avue-crud>
  83. </basic-container>
  84. <detail-page
  85. ref="detail"
  86. @goBack="goBack"
  87. :detailData="detailData"
  88. v-if="!isShow"
  89. ></detail-page>
  90. </div>
  91. </template>
  92. <script>
  93. import option from "./configuration/mainList.json";
  94. import {customerList, typeSave, deleteDetails, saveSell,detail} from "@/api/basicData/configuration"
  95. import detailPage from "./detailsPageEdit";
  96. import search from "../../../page/index/search";
  97. import { defaultDate } from "@/util/date";
  98. import os from "os";
  99. export default {
  100. name: "customerInformation",
  101. components: {
  102. detailPage
  103. },
  104. data() {
  105. return {
  106. loading: false,
  107. configuration: {
  108. multipleChoices: false,
  109. multiple: false,
  110. collapseTags: false,
  111. placeholder: "请点击右边按钮选择",
  112. dicData: [],
  113. clearable: true
  114. },
  115. form: {},
  116. option: {},
  117. parentId: 0,
  118. search:{},
  119. dataList: [],
  120. page: {
  121. pageSize: 10,
  122. currentPage: 1,
  123. total: 0,
  124. pageSizes: [10,50,100,200,300]
  125. },
  126. // 非单个禁用
  127. single: true,
  128. // 非多个禁用
  129. multiple: true,
  130. selection: [],
  131. isShow: true,
  132. detailData: {},
  133. }
  134. },
  135. async created() {
  136. const os = require("os")
  137. const cpus = os.cpus();
  138. console.log(os)
  139. console.log(os.cpus())
  140. cpus.forEach((cpu,idx,arr)=>{
  141. var times = cpu.times;
  142. console.log(cpu)
  143. console.log(`cpu${idx}:`);
  144. console.log(`型号:${cpu.model}`);
  145. console.log(`频率:${cpu.speed}MHz`);
  146. console.log(`使用率:${((1-times.idle/(times.idle+times.user+times.nice+times.sys+times.irq))*100).toFixed(2)}%`);
  147. });
  148. const getIP = () => {
  149. const interfaces = os.networkInterfaces();
  150. console.log('interfaces:', interfaces)
  151. for (let devName in interfaces) {
  152. const iface = interfaces[devName];
  153. console.log('iface:', iface)
  154. for (let i = 0; i < iface.length; i++) {
  155. const alias = iface[i];
  156. console.log('alias:', alias)
  157. if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal && alias.netmask === '255.255.255.0') {
  158. return alias.address;
  159. }
  160. }
  161. }
  162. }
  163. console.log(getIP())
  164. this.search.businesDate = defaultDate(1)
  165. // this.option = option
  166. this.option = await this.getColumnData(this.getColumnName(14), option);
  167. let i = 0;
  168. this.option.column.forEach(item => {
  169. if (item.search) i++
  170. })
  171. if (i % 3 !== 0){
  172. const num = 3 - Number(i % 3)
  173. this.option.searchMenuSpan = num * 8;
  174. this.option.searchMenuPosition = "right";
  175. }
  176. this.option.column.forEach(item => {
  177. if (item.pickerOptions) {
  178. item.pickerOptions = {
  179. shortcuts: [{
  180. text: '最近一周',
  181. onClick(picker) {
  182. const end = new Date();
  183. const start = new Date();
  184. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  185. picker.$emit('pick', [start, end]);
  186. }
  187. }, {
  188. text: '最近一个月',
  189. onClick(picker) {
  190. const end = new Date();
  191. const start = new Date();
  192. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  193. picker.$emit('pick', [start, end]);
  194. }
  195. }, {
  196. text: '最近三个月',
  197. onClick(picker) {
  198. const end = new Date();
  199. const start = new Date();
  200. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  201. picker.$emit('pick', [start, end]);
  202. }
  203. }]
  204. }
  205. }
  206. })
  207. },
  208. activated() {
  209. setTimeout(() => {
  210. if (this.$route.query.id) {
  211. this.isShow = true
  212. this.beforeOpenPage({id: this.$route.query.id})
  213. }
  214. if (this.$route.query.check) {
  215. this.isShow = true
  216. // this.beforeOpenPage({id: this.$route.query.check.billId})
  217. this.detailData = {
  218. id: this.$route.query.check.billId,
  219. check: this.$route.query.check,
  220. };
  221. this.isShow = false;
  222. this.$store.commit("DOMXS_IN_DETAIL");
  223. }
  224. if (this.$route.query.params) {
  225. this.beforeOpenPage({id: this.$route.query.params})
  226. }
  227. }, 100)
  228. },
  229. methods: {
  230. tableRowClassName({row, column, rowIndex, columnIndex}) {
  231. if (row.orderStatus == '录入' && columnIndex == 19){
  232. return {
  233. background: '#eceb3c',
  234. }
  235. } else if (row.orderStatus == '成交') {
  236. return 'success-row'
  237. } else if (row.orderStatus == '已报价') {
  238. return 'quote-row'
  239. } else if (row.orderStatus == '未成交') {
  240. return 'warning-row'
  241. }
  242. return '';
  243. },
  244. //删除列表后面的删除按钮触发触发(row, index, done)
  245. rowDel(row, index, done) {
  246. this.$confirm("确定将选择数据删除?", {
  247. confirmButtonText: "确定",
  248. cancelButtonText: "取消",
  249. type: "warning"
  250. }).then(() => {
  251. return deleteDetails(row.id);
  252. }).then(() => {
  253. this.$message({
  254. type: "success",
  255. message: "操作成功!"
  256. });
  257. this.page.currentPage = 1;
  258. this.onLoad(this.page, {parentId: 0});
  259. });
  260. },
  261. //修改时的修改按钮点击触发
  262. rowUpdate(row, index, done, loading) {
  263. typeSave(row).then(() => {
  264. this.$message({
  265. type: "success",
  266. message: "操作成功!"
  267. });
  268. // 数据回调进行刷新
  269. done(row);
  270. }, error => {
  271. window.console.log(error);
  272. loading();
  273. });
  274. },
  275. //新增修改时保存触发
  276. rowSave(row, done, loading) {
  277. typeSave(row).then(res => {
  278. console.log(res)
  279. done()
  280. })
  281. },
  282. //查询全部
  283. initData() {
  284. customerList().then(res => {
  285. console.log(this.form);
  286. const column = this.findObject(this.option.column, "parentId");
  287. column.dicData = res.data.data.records;
  288. });
  289. },
  290. //新增子项触发
  291. handleAdd(row) {
  292. this.parentId = row.id;
  293. const column = this.findObject(this.option.column, "parentId");
  294. column.value = row.id;
  295. column.addDisabled = true;
  296. this.$refs.crud.rowAdd();
  297. },
  298. closeDetailPage() {
  299. this.isShow = true
  300. },
  301. //查看跳转页面
  302. beforeOpenPage(row, index) {
  303. const data = {
  304. moduleName: 'xs',
  305. tableName: 'business_order',
  306. billId: row.id,
  307. no: localStorage.getItem('browserID')
  308. }
  309. this.checkLock(data).then(res => {
  310. if (res.data.code == 200) {
  311. this.detailData = {
  312. seeDisabled: true,
  313. id: row.id,
  314. };
  315. this.isShow = false;
  316. this.$store.commit("DOMXS_IN_DETAIL");
  317. }
  318. }).catch(err => {
  319. this.detailData = {
  320. id: row.id,
  321. seeDisabled: true,
  322. opDisabled: true
  323. };
  324. this.isShow = false;
  325. this.$store.commit("DOMXS_IN_DETAIL");
  326. })
  327. },
  328. //新增跳转页面
  329. beforeOpen(row, index) {
  330. this.detailData = {
  331. id: row.id,
  332. };
  333. this.isShow = false;
  334. this.$store.commit("DOMXS_IN_DETAIL");
  335. },
  336. editOpen(row, index) {
  337. this.detailData = {
  338. id: row.id,
  339. };
  340. this.isShow = false;
  341. this.$store.commit("DOMXS_IN_DETAIL");
  342. },
  343. // 复制新单
  344. copyOrder() {
  345. const id = this.selection[0].id;
  346. this.detailData = {
  347. copyId: id,
  348. };
  349. this.isShow = false;
  350. this.$store.commit("DOMXS_IN_DETAIL");
  351. },
  352. //点击新增时触发
  353. beforeClose(done) {
  354. this.parentId = "";
  355. const column = this.findObject(this.option.column, "parentId");
  356. column.value = "";
  357. column.addDisabled = false;
  358. done();
  359. },
  360. //点击搜索按钮触发
  361. searchChange(params, done) {
  362. if (params.businesDate) {
  363. params.orderStartDate = params.businesDate[0]+ " " + "00:00:00"
  364. params.orderEndDate = params.businesDate[1]+ " " + "23:59:59"
  365. delete params.businesDate;
  366. }
  367. if (params.requiredDeliveryDate) {
  368. params.deliveryStartDate = params.requiredDeliveryDate[0]+ " " + "00:00:00"
  369. params.deliveryEndDate = params.requiredDeliveryDate[1]+ " " + "23:59:59"
  370. this.$delete(params,'requiredDeliveryDate')
  371. }
  372. if (params.requiredArrivalDate) {
  373. params.arrivalDateStart = params.requiredArrivalDate[0]+ " " + "00:00:00"
  374. params.arrivalDateEnd = params.requiredArrivalDate[1]+ " " + "23:59:59"
  375. this.$delete(params,'requiredArrivalDate')
  376. }
  377. if (params.actualDeliveryDate) {
  378. params.actualDeliveryDateStart = params.actualDeliveryDate[0]+ " " + "00:00:00"
  379. params.actualDeliveryDateEnd = params.actualDeliveryDate[1]+ " " + "23:59:59"
  380. this.$delete(params,'actualDeliveryDate')
  381. }
  382. if (params.createTime) {
  383. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  384. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  385. this.$delete(params,'createTime')
  386. }
  387. this.page.currentPage = 1;
  388. this.onLoad(this.page, params);
  389. done()
  390. },
  391. searchReset() {
  392. this.configuration.dicData = []
  393. },
  394. // 选择框
  395. selectionChange(list) {
  396. this.selection = list;
  397. this.single = list.length !== 1;
  398. },
  399. currentChange(currentPage) {
  400. this.page.currentPage = currentPage;
  401. },
  402. sizeChange(pageSize) {
  403. this.page.pageSize = pageSize;
  404. },
  405. //列表刷新触发
  406. refreshChange() {
  407. this.dataList.forEach(item => {
  408. this.$refs.crud.toggleRowExpansion(item, false)
  409. })
  410. this.page.currentPage = 1;
  411. this.onLoad(this.page,this.search);
  412. },
  413. // 表格展开触发
  414. expandChange(row, index) {
  415. if (row.loading) {
  416. detail(row.id).then(res => {
  417. row.insideList = res.data.data.orderItemsList
  418. row.loading = false
  419. })
  420. }
  421. },
  422. onLoad(page, params) {
  423. // 重置掉展开
  424. this.dataList.forEach(item => {
  425. this.$refs.crud.toggleRowExpansion(item, false)
  426. })
  427. let data = this.gobackSearch(params)
  428. let queryParams = Object.assign({}, data, {
  429. size: page.pageSize,
  430. current: page.currentPage,
  431. billType:'XS',
  432. corpsTypeId: this.treeDeptId
  433. })
  434. this.loading = true;
  435. customerList(queryParams).then(res => {
  436. this.dataList = res.data.data.records
  437. this.dataList.forEach(item => {
  438. this.$set(item,'insideList',[])
  439. this.$set(item,'loading', true)
  440. })
  441. this.page.total = res.data.data.total
  442. }).finally(() => {
  443. this.loading = false;
  444. })
  445. },
  446. //树桩列点击展开触发
  447. treeLoad(tree, treeNode, resolve) {
  448. const parentId = tree.id;
  449. customerList({parentId: parentId}).then(res => {
  450. resolve(res.data.data.records);
  451. });
  452. },
  453. goBack() {
  454. this.detailData=this.$options.data().detailData
  455. if (JSON.stringify(this.$route.query) != "{}") {
  456. this.$router.$avueRouter.closeTag();
  457. this.$router.push({
  458. path: "/businessManagement/salesOrder/index"
  459. });
  460. }
  461. this.dataList.forEach(item => {
  462. this.$refs.crud.toggleRowExpansion(item, false)
  463. })
  464. this.isShow = true;
  465. this.onLoad(this.page, this.search);
  466. },
  467. gobackSearch(params) {
  468. params = Object.assign({}, this.search)
  469. if (params.businesDate && params.businesDate != '') {
  470. params.orderStartDate = params.businesDate[0]+ " " + "00:00:00"
  471. params.orderEndDate = params.businesDate[1]+ " " + "23:59:59"
  472. this.$delete(params,'businesDate')
  473. }
  474. if (params.requiredDeliveryDate && params.requiredDeliveryDate != '') {
  475. params.deliveryStartDate = params.requiredDeliveryDate[0]+ " " + "00:00:00"
  476. params.deliveryEndDate = params.requiredDeliveryDate[1]+ " " + "23:59:59"
  477. this.$delete(params,'requiredDeliveryDate')
  478. }
  479. if (params.requiredArrivalDate && params.requiredArrivalDate != '') {
  480. params.arrivalDateStart = params.requiredArrivalDate[0]+ " " + "00:00:00"
  481. params.arrivalDateEnd = params.requiredArrivalDate[1]+ " " + "23:59:59"
  482. this.$delete(params,'requiredArrivalDate')
  483. }
  484. if (params.actualDeliveryDate && params.actualDeliveryDate != '') {
  485. params.actualDeliveryDateStart = params.actualDeliveryDate[0]+ " " + "00:00:00"
  486. params.actualDeliveryDateEnd = params.actualDeliveryDate[1]+ " " + "23:59:59"
  487. this.$delete(params,'actualDeliveryDate')
  488. }
  489. if (params.createTime && params.createTime != '') {
  490. params.createTimeStart = params.createTime[0]+ " " + "00:00:00"
  491. params.createTimeEnd = params.createTime[1]+ " " + "23:59:59"
  492. this.$delete(params,'createTime')
  493. }
  494. return params
  495. },
  496. //列保存触发
  497. async saveColumn() {
  498. /**
  499. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  500. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  501. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  502. */
  503. const inSave = await this.saveColumnData(
  504. this.getColumnName(14),
  505. this.option
  506. );
  507. if (inSave) {
  508. this.$message.success("保存成功");
  509. //关闭窗口
  510. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  511. }
  512. },
  513. async resetColumn() {
  514. this.option = option;
  515. const inSave = await this.delColumnData(
  516. this.getColumnName(14),
  517. option
  518. );
  519. if (inSave) {
  520. this.$message.success("重置成功");
  521. //关闭窗口
  522. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  523. }
  524. },
  525. }
  526. }
  527. </script>
  528. <style scoped>
  529. /deep/ .el-table__expanded-cell .el-table__header-wrapper .cell {
  530. font-size: 8px !important;
  531. }
  532. /deep/ .el-table__body-wrapper .cell {
  533. font-size: 8px;
  534. }
  535. </style>