moldDownload.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template slot-scope="scope">
  2. <section>
  3. <!--工具条-->
  4. <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
  5. <el-form :inline="true" :model="filters">
  6. <el-form-item>
  7. <el-input v-model="filters.name" placeholder="请输入模具名称进行搜索"></el-input>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button type="primary" @click="getFileList(filters.name)">查询</el-button>
  11. </el-form-item>
  12. <el-form-item style="float: right;">
  13. <el-dropdown>
  14. <el-button type="primary">
  15. 下载
  16. <i class="el-icon-arrow-down el-icon--right"></i>
  17. </el-button>
  18. <el-dropdown-menu slot="dropdown">
  19. <el-dropdown-item @click.native="download(0)">全部下载</el-dropdown-item>
  20. <el-dropdown-item @click.native="download(1)" divided>模具3D图档</el-dropdown-item>
  21. <el-dropdown-item @click.native="download(2)">模具2D图档</el-dropdown-item>
  22. <el-dropdown-item @click.native="download(3)">零件3D图档</el-dropdown-item>
  23. <el-dropdown-item @click.native="download(4)">零件2D图档</el-dropdown-item>
  24. <el-dropdown-item @click.native="download(5)">保养方案</el-dropdown-item>
  25. </el-dropdown-menu>
  26. </el-dropdown>
  27. </el-form-item>
  28. </el-form>
  29. </el-col>
  30. <!--列表-->
  31. <el-table :data="documents" :height="tableHeight" highlight-current-row v-loading="listLoading" style="width: 100%;" @selection-change="selectionChanged">
  32. <el-table-column type="selection" width="50"></el-table-column>
  33. <el-table-column type="index" width="60"></el-table-column>
  34. <el-table-column label="模具名称">
  35. <template slot-scope="scope">
  36. <router-link :to="'/moldList/' + scope.row.id + '/0'" tag="span" style="color: #409eff;cursor: pointer;">{{scope.row.modelName}}</router-link>
  37. </template>
  38. </el-table-column>
  39. <el-table-column width="250" label="模具3D图档">
  40. <template slot-scope="scope">
  41. <span v-if="scope.row.mould3DFiles.length == 0">未上传</span>
  42. <span v-else-if="scope.row.mould3DFilesState">已通过</span>
  43. <span v-else>未通过</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column width="250" label="模具2D图档">
  47. <template slot-scope="scope">
  48. <span v-if="scope.row.mould2DFiles.length == 0">未上传</span>
  49. <span v-else-if="scope.row.mould2DFilesState">已通过</span>
  50. <span v-else>未通过</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column width="250" label="零件3D图档">
  54. <template slot-scope="scope">
  55. <span v-if="scope.row.sparepart3DFiles.length == 0">未上传</span>
  56. <span v-else-if="scope.row.sparepart3DFilesState">已通过</span>
  57. <span v-else>未通过</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column width="250" label="零件2D图档">
  61. <template slot-scope="scope">
  62. <span v-if="scope.row.sparepart2DFiles.length == 0">未上传</span>
  63. <span v-else-if="scope.row.sparepart2DFilesState">已通过</span>
  64. <span v-else>未通过</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column width="250" label="保养方案">
  68. <template slot-scope="scope">
  69. <span v-if="scope.row.maintainFiles.length == 0">未上传</span>
  70. <span v-else-if="scope.row.maintainFilesState">已通过</span>
  71. <span v-else>未通过</span>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <!--工具条-->
  76. <el-col :span="24" class="toolbar">
  77. <el-pagination
  78. @size-change="handleSizeChange"
  79. @current-change="handleCurrentChange"
  80. :page-sizes="[20 , 50 , 80 , 100 , 200]"
  81. :page-size="20"
  82. layout="total, sizes, prev, pager, next"
  83. :total="total"
  84. style="float:right;"
  85. ></el-pagination>
  86. </el-col>
  87. </section>
  88. </template>
  89. <script>
  90. import util from "../../common/js/util";
  91. export default {
  92. data() {
  93. return {
  94. documents: [],
  95. filters: {
  96. name: "",
  97. value: ""
  98. },
  99. listLoading: false,
  100. page: 1,
  101. size: 20,
  102. total: 0,
  103. tableHeight: 0,
  104. selectedArray: []
  105. };
  106. },
  107. methods: {
  108. //分页
  109. handleCurrentChange(val) {
  110. this.page = val;
  111. this.getFileList();
  112. },
  113. handleSizeChange(val) {
  114. this.size = val;
  115. this.getFileList();
  116. },
  117. //获取列表
  118. getFileList(keyword) {
  119. this.http.post(
  120. this.port.mold.moldFileDowloadList,
  121. {
  122. keyName: keyword,
  123. pageSize: this.size,
  124. pageNum: this.page
  125. },
  126. res => {
  127. if (res.code == "ok") {
  128. this.documents = res.data.list;
  129. this.total = res.data.total;
  130. //对于拿到的所有数据
  131. this.documents.forEach(file => {
  132. var mould2DFilesState = true;
  133. var mould3DFilesState = true;
  134. var sparepart2DFilesState = true;
  135. var sparepart3DFilesState = true;
  136. var maintainFilesState = true;
  137. //看看每种文档中的所有文件
  138. file.mould2DFiles.forEach(item => {
  139. if (item.state != 3) {
  140. mould2DFilesState = false;
  141. }
  142. });
  143. file.mould3DFiles.forEach(item => {
  144. if (item.state != 3) {
  145. mould3DFilesState = false;
  146. }
  147. });
  148. file.sparepart2DFiles.forEach(item => {
  149. if (item.state != 3) {
  150. sparepart2DFilesState = false;
  151. }
  152. });
  153. file.sparepart3DFiles.forEach(item => {
  154. if (item.state != 3) {
  155. sparepart3DFilesState = false;
  156. }
  157. });
  158. file.maintainFiles.forEach(item => {
  159. if (item.state != 3) {
  160. maintainFilesState = false;
  161. }
  162. });
  163. //把计算好的状态装进这个模具对象中
  164. file.mould2DFilesState = mould2DFilesState;
  165. file.mould3DFilesState = mould3DFilesState;
  166. file.sparepart2DFilesState = sparepart2DFilesState;
  167. file.sparepart3DFilesState = sparepart3DFilesState;
  168. file.maintainFilesState = maintainFilesState;
  169. });
  170. } else {
  171. this.$message({
  172. message: res.msg,
  173. type: "error"
  174. });
  175. }
  176. },
  177. error => {
  178. this.$message({
  179. message: error,
  180. type: "error"
  181. });
  182. }
  183. );
  184. },
  185. //点击复选时
  186. selectionChanged(row) {
  187. this.selectedArray = [];
  188. row.forEach(item => {
  189. this.selectedArray.push(item.id);
  190. });
  191. },
  192. //下载
  193. download(type) {
  194. if (this.selectedArray.length == 0) {
  195. this.$message("请选择要下载的文档");
  196. } else {
  197. this.downloadPost(type);
  198. }
  199. },
  200. //具体的下载
  201. downloadPost(type) {
  202. var user = sessionStorage.getItem('user') , token = "";
  203. if(user != null){
  204. token = JSON.parse(user).headImgurl
  205. }
  206. this.http.get(
  207. this.port.mold.moldFileDowloadFile +
  208. "?ids="+ this.selectedArray.join(",") +
  209. "&dwgType=" + type +
  210. "&token=" + token
  211. ,
  212. res => {
  213. this.listLoading = false;
  214. if (res.code == "ok") {
  215. let a = document.createElement('a')
  216. a.setAttribute('download', res.data.split("/")[2]);
  217. a.setAttribute("href", res.data);
  218. a.click();
  219. } else {
  220. this.$message({
  221. message: res.msg,
  222. type: "error"
  223. });
  224. }
  225. },
  226. error => {
  227. this.listLoading = false;
  228. this.$message({
  229. message: error,
  230. type: "error"
  231. });
  232. }
  233. );
  234. }
  235. },
  236. created() {
  237. let height = window.innerHeight;
  238. this.tableHeight = height - 210;
  239. },
  240. mounted() {
  241. this.getFileList();
  242. }
  243. };
  244. </script>
  245. <style scoped>
  246. </style>