timeTaskResult.vue 10 KB

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