importList.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="container mc-box">
  3. <fullscreen :fullscreen.sync="fullscreen" class="container-box">
  4. <div class="titbox">
  5. <h2 class="font-ui">手机客户满意度列表</h2>
  6. <div>
  7. <i class="el-icon-refresh" @click="iconCli(1)"></i>
  8. <i class="el-icon-full-screen" @click="iconCli(2)"></i>
  9. <!-- <i class="el-icon-folder-opened"></i>-->
  10. <!-- <i class="el-icon-view"></i>-->
  11. <!-- <i class="el-icon-more"></i>-->
  12. </div>
  13. </div>
  14. <div style="overflow: hidden">
  15. <div class="search" style="float: left; width: 50%">
  16. <mySearch
  17. :searchList="searchList"
  18. @searchInfo="searchInfo"
  19. ></mySearch>
  20. </div>
  21. <el-upload
  22. style="float: left; width: 50%; margin-top: 20px"
  23. class="upload-demo"
  24. action="http://114.215.71.182:29600/spfm/satisfy/sati/inputMobileSatisfys"
  25. :headers="headers"
  26. :before-remove="beforeRemove"
  27. :before-upload="beforeUploadForm"
  28. :http-request="fileChange"
  29. :show-file-list="false"
  30. :file-list="fileList"
  31. >
  32. <el-button size="small" type="primary">点击上传</el-button>
  33. </el-upload>
  34. </div>
  35. <div class="tabbox">
  36. <el-table
  37. height="calc(100% - 40px)"
  38. v-loading="loading"
  39. class="com-table"
  40. ref="multipleTable"
  41. :data="tableData"
  42. tooltip-effect="dark"
  43. size="small"
  44. border
  45. style="width: 100%"
  46. >
  47. <el-table-column
  48. align="center"
  49. prop="time"
  50. label="期数"
  51. show-overflow-tooltip
  52. >
  53. </el-table-column>
  54. <el-table-column
  55. align="center"
  56. prop="status"
  57. show-overflow-tooltip
  58. label="状态"
  59. >
  60. </el-table-column>
  61. <el-table-column
  62. align="center"
  63. prop="insertt"
  64. show-overflow-tooltip
  65. label="导入时间"
  66. >
  67. </el-table-column>
  68. <el-table-column
  69. align="center"
  70. prop="calculate"
  71. show-overflow-tooltip
  72. label="计算时间"
  73. >
  74. </el-table-column>
  75. <el-table-column align="center" prop="hotline" label="操作">
  76. <template slot-scope="scope">
  77. <el-button
  78. :disabled="scope.row.status == '已计算'"
  79. size="mini"
  80. type="danger"
  81. plain
  82. @click="computedScoures(scope.row)"
  83. >计算</el-button
  84. >
  85. <el-button
  86. size="mini"
  87. @click="exportExcel(scope.row)"
  88. plain
  89. type="success"
  90. >
  91. 导出
  92. </el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <el-pagination
  97. class="pageBox"
  98. @current-change="currchange"
  99. layout="prev, pager, next"
  100. background
  101. :total="total"
  102. >
  103. </el-pagination>
  104. </div>
  105. </fullscreen>
  106. </div>
  107. </template>
  108. <script>
  109. import mySearch from "../../../components/search";
  110. export default {
  111. components: {
  112. mySearch,
  113. },
  114. data() {
  115. return {
  116. headers: {
  117. agileauthtoken: sessionStorage.agileauthtoken.replace(/"/g, ""),
  118. },
  119. json_fields: {
  120. 期数: "time",
  121. 状态: "status",
  122. 导入时间: "insertt",
  123. 计算时间: "calculate",
  124. },
  125. fullscreen: false,
  126. total: 0,
  127. pageSize: 1,
  128. tableData: [],
  129. searchList: [
  130. {
  131. type: "input",
  132. tit: "期数",
  133. value: "",
  134. width: "100%",
  135. options: [],
  136. },
  137. ],
  138. params: {
  139. time: "",
  140. },
  141. loading: false,
  142. fileList: [],
  143. fileName: "",
  144. };
  145. },
  146. methods: {
  147. exportExcel(val) {
  148. var that = this;
  149. require.ensure([], () => {
  150. const { export_json_to_excel } = require("../vendor/Export2Excel");
  151. const tHeader = ["期数", "状态", "导入时间", "计算时间"]; // 导出的表头名
  152. const filterVal = ["time", "status", "insertt", "calculate"]; // 导出的表头字段名
  153. const list = [val];
  154. const data = that.formatJson(filterVal, list);
  155. export_json_to_excel(tHeader, data, `手机客户满意度Excel`); // 导出的表格名称,根据需要自己命名
  156. });
  157. },
  158. formatJson(filterVal, jsonData) {
  159. return jsonData.map((v) => filterVal.map((j) => v[j]));
  160. },
  161. beforeUploadForm(file) {
  162. // 验证文件类型
  163. var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
  164. const extension = testmsg === "xlsx";
  165. if (!extension) {
  166. this.$message({
  167. message: "上传文件只能是excel格式!",
  168. duration: 1000,
  169. showClose: true,
  170. type: "warning",
  171. });
  172. }
  173. return extension;
  174. },
  175. // 提交文件
  176. fileChange(param, type) {
  177. let formData = new FormData();
  178. formData.append("file", param.file);
  179. formData.append("name", param.file.name);
  180. this.loading = true;
  181. this.$http({
  182. url: "/satisfy/sati/inputMobileSatisfys",
  183. method: "post",
  184. headers: {
  185. "Content-Type": "application/json",
  186. },
  187. data: formData,
  188. })
  189. .then((res) => {
  190. this.loading = false;
  191. this.getList(this.params, this.pageSize);
  192. })
  193. .catch((err) => {
  194. this.loading = false;
  195. });
  196. },
  197. beforeRemove(file, fileList) {
  198. return this.$confirm(`确定移除 ${file.name}?`);
  199. },
  200. computedScoures(val) {
  201. this.loading = true;
  202. this.$http({
  203. url: "/satisfy/sati/satisfyCalculate",
  204. method: "post",
  205. headers: {
  206. "Content-Type": "application/json",
  207. },
  208. data: { time: val.time },
  209. }).then((res) => {
  210. this.loading = false;
  211. if (res.data.result == 0) {
  212. this.$message({
  213. message: res.data.desc,
  214. type: "success",
  215. });
  216. this.getList(this.params, this.pageSize);
  217. }
  218. });
  219. },
  220. //搜索数据
  221. searchInfo(v) {
  222. this.params = {};
  223. v[0] ? (this.params.time = v[0]) : "";
  224. this.getList(this.params, this.pageSize);
  225. },
  226. //获取列表
  227. getList(v, n) {
  228. this.loading = true;
  229. this.pageSize = n;
  230. this.$http({
  231. url: "/satisfy/sati/getSatisfyHisAll",
  232. method: "post",
  233. headers: {
  234. "Content-Type": "application/json",
  235. page: '{"pageNo":"' + n + '","pageSize":"10"}',
  236. },
  237. data: v,
  238. }).then((res) => {
  239. this.loading = false;
  240. this.tableData = res.data.data;
  241. this.total = res.data.totalRecord;
  242. });
  243. },
  244. //功能栏
  245. iconCli(v) {
  246. if (v === 1) {
  247. this.getList(this.params, this.pageSize);
  248. }
  249. if (v === 2) {
  250. this.fullscreen = !this.fullscreen;
  251. }
  252. },
  253. // 分页
  254. currchange(v) {
  255. this.pageSize = v;
  256. this.getList(this.params, this.pageSize);
  257. },
  258. },
  259. mounted() {
  260. this.getList(this.params, this.pageSize);
  261. },
  262. };
  263. </script>
  264. <style>
  265. .el-upload-list {
  266. float: right;
  267. }
  268. .el-input__suffix {
  269. cursor: pointer;
  270. }
  271. .mc-box .el-upload {
  272. text-align: right;
  273. }
  274. </style>
  275. <style scoped lang="scss">
  276. .btn-default {
  277. display: inline;
  278. margin-left: 10px;
  279. }
  280. .titbox {
  281. div {
  282. float: right;
  283. i {
  284. font-size: 22px;
  285. margin-left: 20px;
  286. cursor: pointer;
  287. }
  288. }
  289. }
  290. .tabbox {
  291. margin-top: 15px;
  292. }
  293. .pageBox {
  294. text-align: right;
  295. margin-top: 10px;
  296. }
  297. </style>