endTeamList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="">
  3. <div class="">
  4. <div class="tableWrap">
  5. <el-table
  6. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  7. :data="tableList"
  8. >
  9. <el-table-column label="商品编号" prop="sn" align="center">
  10. </el-table-column>
  11. <el-table-column label="商品名称" align="center" prop="name">
  12. </el-table-column>
  13. <el-table-column label="商品类型" align="center" prop="type">
  14. <template slot-scope="scope">
  15. <div>
  16. {{ scope.row.type | shopType }}
  17. </div>
  18. </template>
  19. </el-table-column>
  20. <el-table-column label="具体型号" align="center" prop="specification">
  21. </el-table-column>
  22. <el-table-column label="数量统计" align="center" prop="sellCount">
  23. </el-table-column>
  24. </el-table>
  25. </div>
  26. </div>
  27. <div class="btnWrap" style="margin-top: 20px">
  28. <el-button
  29. type="primary"
  30. v-if="tableList.length > 0"
  31. v-permission="'order/musicalListExport'"
  32. @click="musicalListExport"
  33. >订货清单导出</el-button
  34. >
  35. <el-button
  36. type="primary"
  37. v-if="tableList.length > 0"
  38. v-permission="'order/musicalListDetailExport'"
  39. @click="musicalListDetailExport"
  40. >分发清单导出</el-button
  41. >
  42. <el-button
  43. type="primary"
  44. @click="onDelivery"
  45. v-if="musicalStatus && $helpers.permission('musicGroup/takeEffectOfinstrumentInsurance')"
  46. >确认发货</el-button>
  47. <el-button
  48. type="warning okBtn"
  49. v-if="team_status == 'PREPARE'&&!hasVerifyMusicalList"
  50. v-permission="'order/verifyMusicalList'"
  51. @click="okDetailList"
  52. >乐器清单确认</el-button
  53. >
  54. <!-- <div class="okBtn" v-permission="'order/verifyMusicalList'"
  55. @click="okDetailList">确认</div> -->
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. import { getTeamDetailList, getTeamBaseInfo } from "@/api/buildTeam";
  61. import { getTeamList } from "@/api/teamServer";
  62. import { verifyMusicalList, takeEffectOfinstrumentInsurance } from "@/api/orderManager";
  63. import axios from "axios";
  64. import qs from "qs";
  65. import { getToken, getTenantId } from "@/utils/auth";
  66. import load from "@/utils/loading";
  67. export default {
  68. data() {
  69. return {
  70. teamid: "",
  71. tableList: [],
  72. Fsearch: null,
  73. Frules: null,
  74. team_status: "",
  75. musicalInstrumentsProvideStatus: 0, // 是否确认发货 1已发货
  76. hasVerifyMusicalList:true
  77. };
  78. },
  79. mounted() {
  80. this.init();
  81. },
  82. activated() {
  83. this.init();
  84. },
  85. computed: {
  86. musicalStatus() {
  87. const template = ['PREPARE', 'PROGRESS']
  88. const teamStatus = this.$route.query.team_status
  89. const status = template.includes(teamStatus)
  90. console.log(this.musicalInstrumentsProvideStatus, status)
  91. return !this.musicalInstrumentsProvideStatus && status ? true : false
  92. }
  93. },
  94. methods: {
  95. init() {
  96. this.team_status = this.$route.query.team_status;
  97. this.teamid = this.$route.query.id;
  98. if (this.teamid) {
  99. // getTeamList({ musicGroupId: this.teamid }).then(res=>{
  100. // if(res.code == 200){
  101. // this.hasVerifyMusicalList = res?.data?.rows[0]?.hasVerifyMusicalList
  102. // }
  103. // })
  104. getTeamDetailList({ musicGroupId: this.teamid,deliveryStatus:'1' }).then((res) => {
  105. if (res.code == 200) {
  106. this.tableList = res.data ? res.data : [];
  107. }
  108. });
  109. this.getMusicInfo()
  110. }
  111. },
  112. async getMusicInfo() {
  113. await getTeamBaseInfo({ musicGroupId: this.teamid }).then((res) => {
  114. if (res.code == 200) {
  115. this.musicalInstrumentsProvideStatus = res.data?.musicGroup?.musicalInstrumentsProvideStatus
  116. this.hasVerifyMusicalList = res.data?.musicGroup?.hasVerifyMusicalList
  117. }
  118. });
  119. },
  120. onCancel() {
  121. this.$store.dispatch("delVisitedViews", this.$route);
  122. this.$router.push({ path: "/teamList" });
  123. },
  124. onDelivery() {
  125. this.$confirm('是否确认发货', "提示", {
  126. confirmButtonText: "确定",
  127. cancelButtonText: "取消",
  128. type: "warning",
  129. }).then(async () => {
  130. try {
  131. await takeEffectOfinstrumentInsurance({ musicGroupId: this.teamid })
  132. this.$message.success('确定发货成功')
  133. this.getMusicInfo()
  134. } catch {
  135. //
  136. }
  137. })
  138. },
  139. okDetailList() {
  140. this.$confirm(`是否确认发放清单?`, "提示", {
  141. confirmButtonText: "确定",
  142. cancelButtonText: "取消",
  143. type: "warning",
  144. })
  145. .then(() => {
  146. verifyMusicalList({ musicGroupId: this.teamid }).then((res) => {
  147. if (res.code == 200) {
  148. this.$store.dispatch("delVisitedViews", this.$route);
  149. this.$router.push({
  150. path: "/teamList",
  151. query: { search: this.Fsearch, rules: this.Frules },
  152. });
  153. }
  154. });
  155. })
  156. .catch(() => {});
  157. },
  158. musicalListExport() {
  159. // 报表导出
  160. let url = "/api-web/order/musicalListExport";
  161. let data = {
  162. musicGroupId: this.$route.query.id,
  163. };
  164. const options = {
  165. method: "POST",
  166. headers: {
  167. Authorization: getToken(),
  168. tenantId: getTenantId()
  169. },
  170. data: qs.stringify(data),
  171. url,
  172. responseType: "blob",
  173. };
  174. this.$confirm("您确定导出订货清单", "提示", {
  175. confirmButtonText: "确定",
  176. cancelButtonText: "取消",
  177. type: "warning",
  178. })
  179. .then(() => {
  180. load.startLoading();
  181. axios(options)
  182. .then((res) => {
  183. let blob = new Blob([res.data], {
  184. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  185. type: "application/vnd.ms-excel;charset=utf-8",
  186. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  187. });
  188. let text = new Response(blob).text();
  189. text.then((res) => {
  190. // 判断是否报错
  191. if (res.indexOf("code") != -1) {
  192. let json = JSON.parse(res);
  193. if(json.code == 403) {
  194. this.$message.error(`登录过期,请重新登录!`)
  195. setTimeout(() => {
  196. this.$store.dispatch('user/resetToken').then(() => {
  197. location.reload()
  198. })
  199. }, 1000);
  200. return
  201. }
  202. this.$message.error(json.msg);
  203. } else {
  204. let objectUrl = URL.createObjectURL(blob);
  205. let link = document.createElement("a");
  206. let nowTime = new Date();
  207. let ymd =
  208. nowTime.getFullYear() +
  209. "" +
  210. (nowTime.getMonth() + 1) +
  211. "" +
  212. nowTime.getDate() +
  213. "" +
  214. nowTime.getHours() +
  215. "" +
  216. nowTime.getMinutes();
  217. let fname = this.$route.query.id + "-" + ymd + "订货清单.xls"; //下载文件的名字
  218. link.href = objectUrl;
  219. link.setAttribute("download", fname);
  220. document.body.appendChild(link);
  221. link.click();
  222. }
  223. });
  224. load.endLoading();
  225. })
  226. .catch((error) => {
  227. this.$message.error("导出数据失败,请联系管理员");
  228. load.endLoading();
  229. });
  230. })
  231. .catch(() => {});
  232. },
  233. musicalListDetailExport() {
  234. // 报表导出
  235. let url = "/api-web/order/musicalListDetailExport";
  236. let data = {
  237. musicGroupId: this.$route.query.id,
  238. };
  239. const options = {
  240. method: "POST",
  241. headers: {
  242. Authorization: getToken(),
  243. tenantId: getTenantId()
  244. },
  245. data: qs.stringify(data),
  246. url,
  247. responseType: "blob",
  248. };
  249. this.$confirm("您确定导出分发清单", "提示", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning",
  253. })
  254. .then(() => {
  255. load.startLoading();
  256. axios(options)
  257. .then((res) => {
  258. let blob = new Blob([res.data], {
  259. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  260. type: "application/vnd.ms-excel;charset=utf-8",
  261. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  262. });
  263. let text = new Response(blob).text();
  264. text.then((res) => {
  265. // 判断是否报错
  266. if (res.indexOf("code") != -1) {
  267. let json = JSON.parse(res);
  268. if(json.code == 403) {
  269. this.$message.error(`登录过期,请重新登录!`)
  270. setTimeout(() => {
  271. this.$store.dispatch('user/resetToken').then(() => {
  272. location.reload()
  273. })
  274. }, 1000);
  275. return
  276. }
  277. this.$message.error(json.msg);
  278. } else {
  279. let objectUrl = URL.createObjectURL(blob);
  280. let link = document.createElement("a");
  281. let nowTime = new Date();
  282. let ymd =
  283. nowTime.getFullYear() +
  284. "" +
  285. (nowTime.getMonth() + 1) +
  286. "" +
  287. nowTime.getDate() +
  288. "" +
  289. nowTime.getHours() +
  290. "" +
  291. nowTime.getMinutes();
  292. let fname = this.$route.query.id + "-" + ymd + "分发清单.xls"; //下载文件的名字
  293. link.href = objectUrl;
  294. link.setAttribute("download", fname);
  295. document.body.appendChild(link);
  296. link.click();
  297. }
  298. });
  299. load.endLoading();
  300. })
  301. .catch((error) => {
  302. this.$message.error("导出数据失败,请联系管理员");
  303. load.endLoading();
  304. });
  305. })
  306. .catch(() => {});
  307. },
  308. },
  309. };
  310. </script>
  311. <style lang="scss" scoped>
  312. </style>