orderInfoIndex.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div id="orderInfoIndex">
  3. <div v-if="isList">
  4. <el-card v-loading="loading" style="position: relative;">
  5. <p>采购订单信息列表</p>
  6. <div class="btn_grooup">
  7. <el-button type="primary" size="mini" @click="downLoadMb">下载模板</el-button>
  8. <el-button type="primary" size="mini" @click="importMb">导入</el-button>
  9. <el-button type="primary" size="mini" @click="exportMb">导出</el-button>
  10. <el-button type="primary" size="mini" @click="addDivision">新增</el-button>
  11. <el-button type="primary" size="mini" @click="delItems">删除</el-button>
  12. </div>
  13. <el-super-ux-table
  14. id="data-table"
  15. v-model="tableData"
  16. index
  17. checkbox
  18. :size="size"
  19. :dict="dict"
  20. :page="pageInfo"
  21. :height=500
  22. :columns="TableColumns"
  23. pagination
  24. convenitentOperation
  25. storage-key="orderTable"
  26. @row-dblclick="useSee"
  27. @row-select="useSelect"
  28. @selection-change="handleSelectionChange"
  29. @row-click="rowSelect"
  30. @pagination="useQuery(params, pageInfo)"
  31. ref="tables"
  32. >
  33. <ux-table-column
  34. fixed="right"
  35. title="操作"
  36. align="center"
  37. width="100"
  38. >
  39. <template slot-scope="scope">
  40. <!-- <el-button type="text" size="mini" v-if="scope.row.status == '1' && scope.row.flowId" @click="reback(scope.row)">收回</el-button> -->
  41. <!-- <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button> -->
  42. <el-button type="text" size="mini" @click="delItem(scope.row)">删除</el-button>
  43. </template>
  44. </ux-table-column>
  45. </el-super-ux-table>
  46. </el-card>
  47. </div>
  48. <!-- 用户导入对话框 -->
  49. <el-dialog title="数据导入" :visible.sync="upload.open" width="400px">
  50. <el-upload
  51. ref="upload"
  52. :limit="1"
  53. accept=".xlsx, .xls"
  54. :headers="upload.headers"
  55. :action="upload.url"
  56. :disabled="upload.isUploading"
  57. :on-progress="handleFileUploadProgress"
  58. :on-success="handleFileSuccess"
  59. :on-error="errorFile"
  60. :auto-upload="false"
  61. drag
  62. >
  63. <i class="el-icon-upload"></i>
  64. <div class="el-upload__text">
  65. 将文件拖到此处,或
  66. <em>点击上传</em>
  67. </div>
  68. <div class="el-upload__tip" style="color: red" slot="tip">
  69. 提示:仅允许导入“xls”或“xlsx”格式文件!
  70. </div>
  71. </el-upload>
  72. <div slot="footer">
  73. <el-button :size="size" type="primary" @click="submitFileForm"
  74. >确 定</el-button
  75. >
  76. <el-button :size="size" @click="upload.open = false">取 消</el-button>
  77. </div>
  78. </el-dialog>
  79. <Add v-model="isList" v-if="!isList" :pageStu="page" :disable="disable" :row="rowDetail" @refresh="searchList"/>
  80. </div>
  81. </template>
  82. <script>
  83. import { orderList, delOrder, mbDownload, mbExport, errDownload } from '@/api/innerData/order.js'
  84. // 导入的token
  85. import { getToken } from "@/utils/auth";
  86. export default {
  87. dicts: [],
  88. components: {
  89. Add: () => import("./addOrderInfo.vue"),
  90. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  91. },
  92. data () {
  93. return {
  94. // 页面配置
  95. isList: true,
  96. // 页面状态
  97. page: '',
  98. disable: false,
  99. rowDetail: {},
  100. size: "mini",
  101. loading: false,
  102. params: {},
  103. pageInfo: {
  104. pageNum: 1,
  105. pageSize: 20,
  106. total: 0
  107. },
  108. tableData: [],
  109. selectData: [],
  110. // SearchColumns: SearchColumns,
  111. TableColumns: [
  112. { item: { key: "puOrgName", title: "采购组织" }, attr: {} },
  113. { item: { key: "billTypeName", title: "订单类型" }, attr: {} },
  114. { item: { key: "supplierName", title: "供应商" }, attr: {} },
  115. { item: { key: "orderCode", title: "订单编号" }, attr: {} },
  116. { item: { key: "taxPrice", title: "价税合计" }, attr: {} },
  117. { item: { key: "buyerName", title: "采购员" }, attr: {} },
  118. { item: { key: "materialName", title: "物料名称" }, attr: {} },
  119. { item: { key: "materialCode", title: "物料编码" }, attr: {} },
  120. { item: { key: "specification", title: "规格" }, attr: {} },
  121. { item: { key: "model", title: "型号" }, attr: {} },
  122. { item: { key: "manufacturerName", title: "生产厂家/代理人" }, attr: {} },
  123. { item: { key: "unitName", title: "单位" }, attr: {} },
  124. { item: { key: "qty", title: "数量" }, attr: {} },
  125. { item: { key: "money", title: "含税单价" }, attr: {} },
  126. { item: { key: "sipPrice", title: "内部价格" }, attr: {} },
  127. { item: { key: "sipSupplierName", title: "内部供应商" }, attr: {} },
  128. ].map(({ item, attr }) => ({
  129. attr,
  130. item: {
  131. ...item,
  132. sortabled: true,
  133. fixedabled: true,
  134. filterabled: true,
  135. hiddenabled: true,
  136. },
  137. })),
  138. ids: [],
  139. upload: {
  140. // 是否显示弹出层(导入)
  141. open: false,
  142. // 弹出层标题(导入)
  143. title: "数据导入",
  144. // 是否禁用上传
  145. isUploading: false,
  146. // 是否更新已经存在的用户数据
  147. updateSupport: 1,
  148. // 设置上传的请求头部
  149. headers: { Authorization: "Bearer " + getToken() },
  150. // 上传的地址
  151. url: process.env.VUE_APP_BASE_API + "/sip/order/import",
  152. },
  153. }
  154. },
  155. created() {
  156. this.useQuery(this.params, this.pageInfo)
  157. },
  158. methods: {
  159. // 新增
  160. addDivision() {
  161. this.isList = false
  162. this.page = 'add'
  163. this.disable = false
  164. },
  165. delItems() {
  166. if (this.ids.length <= 0) {
  167. this.$modal.notifyWarning("至少勾选一条数据");
  168. } else {
  169. delOrder(this.ids).then(res => {
  170. if(res.code === 200) {
  171. this.$modal.notifySuccess("删除成功");
  172. this.useQuery(this.params, this.pageInfo)
  173. }
  174. })
  175. }
  176. },
  177. searchList() {
  178. this.useQuery(this.params, this.pageInfo)
  179. },
  180. useSee() {},
  181. useSelect() {},
  182. handleSelectionChange(selection) {
  183. console.log('选中', selection)
  184. this.ids = selection.map(item => item.id)
  185. console.log('选中数组', this.ids)
  186. },
  187. rowSelect(row) {
  188. this.$refs.tables.toggleRowSelection([{row: row}]);
  189. },
  190. // 加载列表
  191. async useQuery(prop, page) {
  192. let params = {...prop, ...page}
  193. await orderList(params).then(res => {
  194. if( res.code === 200 ) {
  195. this.tableData = res.rows
  196. this.pageInfo.total = res.total
  197. }
  198. })
  199. },
  200. delItem(row) {
  201. const param = [row.id]
  202. delOrder(param).then(res => {
  203. if(res.code === 200) {
  204. this.$modal.notifySuccess("删除成功");
  205. this.useQuery(this.params, this.pageInfo)
  206. }
  207. })
  208. },
  209. downLoadMb() {
  210. this.$modal.loading("正在下载模板,请稍后...");
  211. mbDownload().then((res) => {
  212. this.$modal.closeLoading();
  213. const blob = new Blob([res], {
  214. type: "application/vnd.ms-excel;charset=UTF-8",
  215. }); // 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  216. console.log('blob1', blob)
  217. const downloadElement = document.createElement("a"); //创建a标签
  218. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  219. // var temp = res.headers["content-disposition"];
  220. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  221. // var name = fileName.split(";")[0]; //切割成文件名
  222. downloadElement.href = href; //下载地址
  223. downloadElement.download =
  224. "内部订单价格模板" + this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  225. document.body.appendChild(downloadElement);
  226. downloadElement.click(); // 点击下载
  227. document.body.removeChild(downloadElement); // 下载完成移除元素
  228. window.URL.revokeObjectURL(href); // 释放blob对象
  229. this.download.open = false;
  230. })
  231. .catch((err) => {
  232. this.$modal.closeLoading();
  233. });
  234. },
  235. importMb() {
  236. this.upload.title = "用户导入";
  237. this.upload.open = true;
  238. },
  239. // 文件上传中处理
  240. handleFileUploadProgress(event, file, fileList) {
  241. this.upload.isUploading = true;
  242. this.$modal.loading("正在导入数据,请稍后...");
  243. },
  244. // 文件上传成功处理
  245. handleFileSuccess(response, file, fileList) {
  246. this.$modal.closeLoading();
  247. this.upload.open = false;
  248. this.upload.isUploading = false;
  249. this.$refs.upload.clearFiles();
  250. // this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  251. if (response.data && response.data.length !== 0) {
  252. this.$modal.notifyError("导入失败,请检查格式是否正确");
  253. console.log(response.data)
  254. errDownload(response.data).then((res) => {
  255. this.$modal.closeLoading();
  256. const blob = new Blob([res], {
  257. type: "application/vnd.ms-excel;charset=UTF-8",
  258. }); // 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  259. const downloadElement = document.createElement("a"); //创建a标签
  260. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  261. downloadElement.href = href; //下载地址
  262. downloadElement.download ="内部订单价格导入失败" + this.parseTime(new Date().getTime()) +".xlsx"; // 下载后文件名
  263. document.body.appendChild(downloadElement);
  264. downloadElement.click(); // 点击下载
  265. document.body.removeChild(downloadElement); // 下载完成移除元素
  266. window.URL.revokeObjectURL(href); // 释放blob对象
  267. })
  268. .catch((err) => {
  269. this.$modal.closeLoading();
  270. });
  271. } else {
  272. this.$modal.notifySuccess("导入成功");
  273. this.useQuery(this.params, this.pageInfo);
  274. }
  275. console.log('结果',response)
  276. },
  277. errorFile(err) {
  278. this.$modal.closeLoading();
  279. this.$modal.notifyError("文件已变动,请重新上传");
  280. },
  281. // 提交上传文件
  282. submitFileForm() {
  283. this.$refs.upload.submit();
  284. },
  285. exportMb() {
  286. mbExport().then((res) => {
  287. this.$modal.closeLoading();
  288. console.log(res)
  289. const blob = new Blob([res], {
  290. type: "application/vnd.ms-excel;charset=UTF-8",
  291. }); // 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  292. const downloadElement = document.createElement("a"); //创建a标签
  293. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  294. downloadElement.href = href; //下载地址
  295. downloadElement.download ="内部订单价格导出" + this.parseTime(new Date().getTime()) +".xlsx"; // 下载后文件名
  296. document.body.appendChild(downloadElement);
  297. downloadElement.click(); // 点击下载
  298. document.body.removeChild(downloadElement); // 下载完成移除元素
  299. window.URL.revokeObjectURL(href); // 释放blob对象
  300. })
  301. .catch((err) => {
  302. this.$modal.closeLoading();
  303. });
  304. },
  305. }
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. #orderInfoIndex {
  310. padding: 12px;
  311. box-sizing: border-box;
  312. overflow-y: scroll;
  313. }
  314. .btn_grooup {
  315. margin-bottom: 10px;
  316. display: flex;
  317. justify-content: flex-end;
  318. }
  319. </style>