index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <script>
  2. import useColumns from "./columns";
  3. import {
  4. getReqList,
  5. delReq,
  6. importData,
  7. fileImport,
  8. betchSubmit,
  9. toOA,
  10. oaBack,
  11. } from "@/api/requisition/basic";
  12. import { saveAs } from "file-saver";
  13. import { blobValidate } from "@/utils/ruoyi";
  14. import { dicts } from "./dicts";
  15. export default {
  16. name: "requisition",
  17. dicts: [...dicts, "oa_templete_id"],
  18. components: {
  19. DetailsRequsition: () => import("./details/index.vue"),
  20. ElSuperTable: () => import("@/components/super-table/index.vue"),
  21. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  22. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  23. BatchImport: () => import("@/components/BatchImport/index.vue"),
  24. plscButton: () => import("./fun-button/plsc/index.vue"),
  25. pldcButton: () => import("./fun-button/pldc/index.vue"),
  26. },
  27. data() {
  28. const { SearchColumns, TableColumns } = useColumns();
  29. const page = this.$init.page();
  30. const params = this.$init.params(SearchColumns);
  31. return {
  32. loading: false,
  33. size: "mini",
  34. page: page,
  35. params: params,
  36. tableData: [],
  37. selectData: [],
  38. SearchColumns: SearchColumns,
  39. TableColumns: TableColumns,
  40. addType: "add",
  41. };
  42. },
  43. created() {},
  44. mounted() {
  45. this.params.billCode = this.$route.query.billCode;
  46. this.useQuery(this.params, this.page);
  47. },
  48. methods: {
  49. async useQuery(prop, page) {
  50. try {
  51. this.loading = true;
  52. let { code, rows, total } = await getReqList({ ...prop, ...page });
  53. if (code == 200) {
  54. this.tableData = rows;
  55. this.page.total = total;
  56. }
  57. } catch (error) {
  58. console.log(error);
  59. } finally {
  60. this.loading = false;
  61. }
  62. },
  63. // 打开详细
  64. openDetails(option, prop) {
  65. this.addType = option;
  66. let { setVisible, fetchItem } = this.$refs.detailsRequsition;
  67. setVisible(true);
  68. prop && fetchItem(prop);
  69. },
  70. //
  71. handleDbclick(prop) {
  72. this.openDetails("see", prop);
  73. },
  74. handleSelectionChange(selection) {
  75. this.selectData = selection;
  76. },
  77. // 流程跳转
  78. async jumpFlow(row) {
  79. const { name } = this.$store.state.user;
  80. try {
  81. let { code, msg, oaUrl } = await toOA(name, row.oaId);
  82. if (code == 200) {
  83. window.open(oaUrl);
  84. }
  85. } catch (error) {
  86. } finally {
  87. }
  88. },
  89. //流程收回
  90. async handleBack(row) {
  91. try {
  92. const { msg, code } = await oaBack({
  93. fdTemplateId: this.dict.type.oa_templete_id.find((item) => {
  94. return item.label == "物料申请单";
  95. }).value,
  96. fdId: row.oaId,
  97. billCode: row.billCode,
  98. billMaker: row.createBy,
  99. });
  100. if (code === 200) {
  101. this.$emit("success");
  102. this.$notify.success(msg);
  103. }
  104. } catch (err) {
  105. console.error(err);
  106. } finally {
  107. this.getList(this.queryParams);
  108. }
  109. },
  110. // 删行
  111. deleteRow(row) {
  112. this.handleConfirmTips(async () => {
  113. try {
  114. let { code, msg } = await delReq(row.id);
  115. if (code === 200) {
  116. this.useQuery(this.params, this.page);
  117. this.$notify.success(msg);
  118. }
  119. } catch (error) {}
  120. });
  121. },
  122. reset() {
  123. this.page = this.$init.page();
  124. this.params = this.$init.params(this.SearchColumns);
  125. this.useQuery(this.params, this.page);
  126. },
  127. // 批量提交
  128. batchSubmit() {
  129. let filterList = this.selectData.filter(
  130. (item) => !(item.status === "0" || item.status === "3")
  131. );
  132. if (!filterList.length && this.selectData.length) {
  133. this.handleConfirmTips(async () => {
  134. try {
  135. this.loading = true;
  136. let ids = this.selectData.map((item) => Number(item.id));
  137. let { code, msg } = await betchSubmit({ ids });
  138. if (code == 200) {
  139. this.$notify.success({
  140. message: msg,
  141. });
  142. this.reset();
  143. } else {
  144. this.$notify.error({
  145. message: msg,
  146. });
  147. }
  148. } catch (error) {
  149. } finally {
  150. this.loading = false;
  151. }
  152. });
  153. } else {
  154. this.$notify.warning({
  155. message: "存在不符合提交条件数据或未选择数据!",
  156. });
  157. }
  158. },
  159. // 导入
  160. async handelImport(fileList) {
  161. let formData = new FormData();
  162. formData.append("file", fileList[0].raw);
  163. let { setVisible } = this.$refs.batchImport;
  164. setVisible(false);
  165. try {
  166. this.loading = true;
  167. let { code, msg, data } = await importData(formData);
  168. if (code == 200) {
  169. // 存在导入失败的数据
  170. data.flag && (await this.exportfail(data.datas));
  171. this.$notify({
  172. message: data.msg,
  173. type: data.flag ? "warning" : "success",
  174. });
  175. } else {
  176. this.$notify({
  177. message: msg,
  178. type: code == 200 ? "success" : "warning",
  179. });
  180. }
  181. } catch (error) {
  182. } finally {
  183. this.loading = false;
  184. }
  185. },
  186. // 导出失败数据
  187. async exportfail(prop) {
  188. try {
  189. this.loading = true;
  190. let res = await fileImport({ failDatas: prop });
  191. const isBlob = blobValidate(res);
  192. if (isBlob) {
  193. const blob = new Blob([res]);
  194. await saveAs(blob, "导入失败的物料申请单数据.xlsx");
  195. this.reset();
  196. }
  197. } catch (error) {
  198. } finally {
  199. this.loading = false;
  200. }
  201. },
  202. // 模板下载,
  203. handleTemDownload() {
  204. this.download("/system/apply/material/download", {}, "申请单模板.xlsx");
  205. },
  206. // 操作提示弹窗
  207. handleConfirmTips(success) {
  208. this.$confirm("是否继续此操作?", "提示", {
  209. confirmButtonText: "确定",
  210. cancelButtonText: "取消",
  211. type: "warning",
  212. })
  213. .then(() => {
  214. success();
  215. })
  216. .catch(() => {});
  217. },
  218. },
  219. };
  220. </script>
  221. <template>
  222. <el-card
  223. v-loading="loading"
  224. :body-style="{
  225. height: '100%',
  226. padding: 0,
  227. display: 'flex',
  228. 'flex-direction': 'column',
  229. }"
  230. >
  231. <el-super-search
  232. v-model="params"
  233. :size="size"
  234. :dict="dict"
  235. :columns="SearchColumns"
  236. @reset="reset"
  237. @submit="useQuery(params, page)"
  238. ></el-super-search>
  239. <el-row :gutter="24" type="flex" justify="end" style="margin: 16px 0 12px">
  240. <el-col :span="24" style="text-align: right">
  241. <el-button-group style="margin-left: 10px">
  242. <el-button :size="size" type="primary" @click="openDetails('add')"
  243. >新增</el-button
  244. >
  245. <el-button
  246. :size="size"
  247. :disabled="selectData.length !== 1"
  248. @click="openDetails('add', selectData[0])"
  249. >复制</el-button
  250. >
  251. </el-button-group>
  252. <el-button-group style="margin: 0 10px">
  253. <el-button :size="size" @click="batchSubmit">批量提交</el-button>
  254. </el-button-group>
  255. <BatchImport
  256. ref="batchImport"
  257. @import="handelImport"
  258. @temDownload="handleTemDownload"
  259. :fileSize="2"
  260. ></BatchImport>
  261. <plsc-button
  262. :size="size"
  263. :select-data="selectData"
  264. @success="useQuery(params, page)"
  265. ></plsc-button>
  266. <pldc-button
  267. :size="size"
  268. :queryParams="params"
  269. :select-data="selectData"
  270. @success="useQuery(params, page)"
  271. ></pldc-button>
  272. </el-col>
  273. </el-row>
  274. <el-super-ux-table
  275. v-model="tableData"
  276. :dict="dict"
  277. :columns="TableColumns"
  278. :size="size"
  279. pagination
  280. index
  281. checkbox
  282. convenitentOperation
  283. :page="page"
  284. storage-key="MaterialRequisitionSuperTable"
  285. @pagination="useQuery(params, page)"
  286. @row-dblclick="handleDbclick"
  287. @selection-change="handleSelectionChange"
  288. >
  289. <ux-table-column fixed="right" title="操作" align="center" width="180">
  290. <template slot-scope="scope">
  291. <el-button
  292. type="text"
  293. :size="size"
  294. @click.stop="openDetails('see', scope.row)"
  295. >查看</el-button
  296. >
  297. <el-button
  298. @click.stop="openDetails('edit', scope.row)"
  299. v-if="scope.row.status == 0 || scope.row.status == 3"
  300. type="text"
  301. :size="size"
  302. >编辑</el-button
  303. >
  304. <el-button
  305. @click.stop="jumpFlow(scope.row)"
  306. v-if="scope.row.oaId && scope.row.oaId != ''"
  307. type="text"
  308. :size="size"
  309. >流程跳转</el-button
  310. >
  311. <el-button
  312. type="text"
  313. :size="size"
  314. @click.stop="deleteRow(scope.row)"
  315. v-if="scope.row.status == 0 || scope.row.status == 3"
  316. >删除</el-button
  317. >
  318. <el-button
  319. v-if="
  320. scope.row.status == '1' && scope.row.oaId && scope.row.oaId != ''
  321. "
  322. type="text"
  323. :size="size"
  324. @click.stop="handleBack(scope.row)"
  325. >流程收回</el-button
  326. >
  327. </template>
  328. </ux-table-column>
  329. </el-super-ux-table>
  330. <details-requsition
  331. ref="detailsRequsition"
  332. :addType="addType"
  333. :dict="dict"
  334. :size="size"
  335. @success="useQuery(params, page)"
  336. ></details-requsition>
  337. </el-card>
  338. </template>
  339. <style scoped lang="scss">
  340. .el-card {
  341. width: calc(100% - 32px);
  342. height: calc(100vh - 32px);
  343. margin: 16px;
  344. padding: 16px;
  345. border-radius: 8px;
  346. }
  347. </style>