countResult.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. // 计次作业
  2. <template>
  3. <div class="sale">
  4. <div class="top">
  5. <!-- 框计算 -->
  6. <span class="text">计次时间:</span>
  7. <el-date-picker
  8. v-model="startTime"
  9. type="datetime"
  10. placeholder="选择日期"
  11. >
  12. </el-date-picker>
  13. <span class="text">至</span>
  14. <el-date-picker v-model="endTime" type="datetime" placeholder="选择日期">
  15. </el-date-picker>
  16. <el-button type="primary" class="btn" @click="onclick">
  17. <i class="el-icon-search"></i>查询
  18. </el-button>
  19. <!-- excel导出 -->
  20. <el-button type="primary" @click="exportAllExcel()">
  21. <i class="el-icon-download"></i>导出(Excel)
  22. </el-button>
  23. </div>
  24. <div class="tab">
  25. <dilTable v-bind.sync="option" ref="excelDom">
  26. <el-table-column fixed="right" label="操作" width="180">
  27. <template slot-scope="scope">
  28. <div class="step">
  29. <el-button
  30. @click="detailclick1(scope.row)"
  31. type="text"
  32. size="small"
  33. >运输详情</el-button
  34. >
  35. </div>
  36. <!-- <el-button @click="" type="primary" style="margin-left: 16px;">
  37. 运输详情
  38. </el-button> -->
  39. </template>
  40. </el-table-column>
  41. <!-- 运输进程详情 -->
  42. <el-table-column type="expand" width="1">
  43. <template slot-scope="props">
  44. <el-form label-position="center" inline class="demo-table-expand">
  45. <div v-if="false">{{ props }}</div>
  46. <div>
  47. <el-table :data="tableData1" border>
  48. <el-table-column
  49. v-for="(item, i) in tableHead"
  50. :key="i"
  51. :prop="item.prop"
  52. :label="item.label"
  53. :width="item.width"
  54. ></el-table-column>
  55. </el-table>
  56. </div>
  57. </el-form>
  58. </template>
  59. </el-table-column>
  60. </dilTable>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import { getCookie } from "@/utils/util.js";
  66. import { sjTime } from "@/utils/sharedJsFile";
  67. export default {
  68. data() {
  69. return {
  70. inputText: "",
  71. option: {
  72. // 表格请求数据的地址
  73. requestUrl: ""
  74. },
  75. tableHead: [
  76. {
  77. prop: "linkName",
  78. label: "计次状态",
  79. width: 150
  80. },
  81. {
  82. prop: "pointDate",
  83. label: "时间",
  84. width: 150
  85. }
  86. ],
  87. tableData1: [],
  88. tableData: [],
  89. startTime: null,
  90. endTime: null,
  91. oldRow1: "",
  92. oldRowCount1: 1,
  93. drawer: false,
  94. direction: "rtl",
  95. orderId: 0,
  96. stepList: [],
  97. tableTitle: "计次统计",
  98. exportAllList:[],
  99. noSettleDetailsColumn:[]
  100. };
  101. },
  102. created() {
  103. if (
  104. getCookie("orgCode") == "dagangadmin" ||
  105. getCookie("orgCode") == "zidonghuabu" ||
  106. getCookie("orgCode") == "wuliuchuyunzhongxin"
  107. ) {
  108. this.option.requestUrl = "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26";
  109. } else {
  110. this.option.requestUrl =
  111. "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26&userId=" +
  112. getCookie("orgCode");
  113. }
  114. },
  115. methods: {
  116. exportAllExcel() {
  117. this.tableTitle = '计次统计'
  118. let startTime = null;
  119. let endTime = null;
  120. if (this.startTime) {
  121. startTime = sjTime(this.startTime);
  122. }
  123. if (this.endTime) {
  124. endTime = sjTime(this.endTime);
  125. }
  126. if (startTime && endTime) {
  127. if (startTime < endTime) {
  128. console.log(startTime);
  129. console.log(endTime);
  130. if (
  131. getCookie("orgCode") == "dagangadmin" ||
  132. getCookie("orgCode") == "zidonghuabu" ||
  133. getCookie("orgCode") == "wuliuchuyunzhongxin"
  134. ) {
  135. this.axios
  136. .post(
  137. "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26&startTime=" +
  138. startTime +
  139. "&endTime=" +
  140. endTime +
  141. "&i=" +
  142. new Date()
  143. )
  144. .then(res => {
  145. console.log(res.data.data)
  146. console.log(res.data.data)
  147. this.exportAllList = res.data.data.list
  148. this.noSettleDetailsColumn=res.data.data.columnData
  149. this.exportAllReportToExcel(
  150. this.tableTitle,
  151. this.exportAllList,
  152. this.noSettleDetailsColumn
  153. )
  154. })
  155. } else {
  156. this.axios
  157. .post(
  158. "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26&userId=" +
  159. getCookie("orgCode") +
  160. "&startTime=" +
  161. startTime +
  162. "&endTime=" +
  163. endTime +
  164. "&i=" +
  165. new Date()
  166. )
  167. .then(res => {
  168. console.log(res.data.data)
  169. console.log(res.data.data)
  170. this.exportAllList = res.data.data.list
  171. this.noSettleDetailsColumn=res.data.data.columnData
  172. this.exportAllReportToExcel(
  173. this.tableTitle,
  174. this.exportAllList,
  175. this.noSettleDetailsColumn
  176. )
  177. })
  178. }
  179. } else {
  180. this.startTime = null;
  181. this.endTime = null;
  182. this.$message.warning("开始时间要比结束时间早");
  183. }
  184. } else {
  185. }
  186. },
  187. //导出excel
  188. exportAllReportToExcel(tableTitle, dataArr, columnData) {
  189. var title = tableTitle
  190. let tHeader = []
  191. let filterVal = []
  192. columnData.forEach(e1 => {
  193. if (tHeader.indexOf(e1.label) === -1) {
  194. tHeader.push(e1.label)
  195. }
  196. if (filterVal.indexOf(e1.prop) === -1) {
  197. filterVal.push(e1.prop)
  198. }
  199. })
  200. //导出为excel
  201. this.downloadLoading = true
  202. require.ensure([], () => {
  203. const {
  204. export_json_to_excel
  205. } = require('@/assets/excel/Export2Excel.js') //这里必须使用绝对路径,使用@/+存放export2Excel的路径
  206. // let list = this.$refs.excelDom.dataTabel;
  207. let data = dataArr.map(v => filterVal.map(j => v[j])) //3.formatJson格式转换
  208. export_json_to_excel(tHeader, data, title) // (title)导出的表格名称
  209. })
  210. },
  211. // -------查看物资详情(已拒绝)
  212. detailclick1(row) {
  213. // 记录重复点击次数
  214. if (this.oldRow1 === row) {
  215. this.oldRowCount1 += 1;
  216. }
  217. this.orderId = row.orderId;
  218. let map = {
  219. orderId: this.orderId
  220. };
  221. // 切换当前详情表
  222. this.$refs.excelDom.toggleRowExpansion(row);
  223. // 打开前关闭上一个详情表
  224. if (this.oldRow1 != "") {
  225. if (this.oldRow1 != row) {
  226. if (this.oldRowCount1 % 2 === 1) {
  227. this.$refs.excelDom.toggleRowExpansion(this.oldRow1);
  228. } else {
  229. this.oldRowCount1 = 1;
  230. }
  231. } else {
  232. this.oldRow1 = null;
  233. return;
  234. }
  235. }
  236. // 重置上一个点击对象
  237. this.oldRow1 = row;
  238. // 根据销售订单物资中间表id查询物资信息
  239. this.axios.post("/api/v1/oms/getOrderResult?orderId=", map).then(res => {
  240. console.log("res", res);
  241. this.tableData1 = res.data;
  242. });
  243. },
  244. getStepsList(row) {
  245. console.log(row.orderId);
  246. this.orderId = row.orderId;
  247. this.drawer = true;
  248. let map = {
  249. orderId: this.orderId
  250. };
  251. this.axios.post("/api/v1/oms/getOrderResult", map).then(res => {
  252. console.log(res);
  253. if (res.status == 200) {
  254. this.stepList = res.data;
  255. } else {
  256. this.$message.error("展示失败!");
  257. }
  258. });
  259. console.log(this.stepList);
  260. },
  261. getRequirementMaterial1(row) {
  262. // 记录重复点击次数
  263. if (this.oldRow1 === row) {
  264. this.oldRowCount1 += 1;
  265. }
  266. // 切换当前详情表
  267. this.$refs.excelDom.toggleRowExpansion(row);
  268. // 打开前关闭上一个详情表
  269. if (this.oldRow1 != "") {
  270. if (this.oldRow1 != row) {
  271. if (this.oldRowCount1 % 2 === 1) {
  272. this.$refs.excelDom.toggleRowExpansion(this.oldRow1);
  273. } else {
  274. this.oldRowCount1 = 1;
  275. }
  276. } else {
  277. this.oldRow1 = null;
  278. return;
  279. }
  280. }
  281. // 重置上一个点击对象
  282. this.oldRow1 = row;
  283. this.getMaterial(row.orderId);
  284. },
  285. onclick() {
  286. let startTime = null;
  287. let endTime = null;
  288. if (this.startTime) {
  289. startTime = sjTime(this.startTime);
  290. }
  291. if (this.endTime) {
  292. endTime = sjTime(this.endTime);
  293. }
  294. if (startTime && endTime) {
  295. if (startTime < endTime) {
  296. console.log(startTime);
  297. console.log(endTime);
  298. if (
  299. getCookie("orgCode") == "dagangadmin" ||
  300. getCookie("orgCode") == "zidonghuabu" ||
  301. getCookie("orgCode") == "wuliuchuyunzhongxin"
  302. ) {
  303. this.option.requestUrl =
  304. "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26&startTime=" +
  305. startTime +
  306. "&endTime=" +
  307. endTime +
  308. "&i=" +
  309. new Date();
  310. } else {
  311. this.option.requestUrl =
  312. "/api/v1/tms/getAllTimeTaskResult?apiId=458&orderType=26&userId=" +
  313. getCookie("orgCode") +
  314. "&startTime=" +
  315. startTime +
  316. "&endTime=" +
  317. endTime +
  318. "&i=" +
  319. new Date();
  320. }
  321. } else {
  322. this.startTime = null;
  323. this.endTime = null;
  324. this.$message.warning("开始时间要比结束时间早");
  325. }
  326. } else {
  327. }
  328. },
  329. getMaterial(orderId) {
  330. console.log(orderId);
  331. this.axios
  332. .post("/api/v1/oms/getPauseTimeTaskDetail/" + orderId)
  333. .then(res => {
  334. console.log(res);
  335. this.tableData = res.data.data;
  336. });
  337. }
  338. }
  339. };
  340. </script>
  341. <style lang="scss">
  342. .sale {
  343. .top {
  344. padding: 1.25rem 1.875rem;
  345. .el-input {
  346. width: 20%;
  347. }
  348. }
  349. }
  350. .el-table th.el-table__cell > .cell {
  351. display: inline-block;
  352. -webkit-box-sizing: border-box;
  353. box-sizing: border-box;
  354. position: relative;
  355. vertical-align: middle;
  356. padding-left: 10px;
  357. padding-right: 10px;
  358. width: 100%;
  359. text-align: center;
  360. }
  361. .step {
  362. text-align: center;
  363. }
  364. </style>