index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <template>
  2. <div class="requisition" v-loading="failLoad">
  3. <div class="applyList" v-if="isList">
  4. <el-card>
  5. <el-super-search
  6. v-model="params"
  7. :size="size"
  8. :dict="dict"
  9. :columns="SearchColumns"
  10. @reset="reset"
  11. @submit="getList"
  12. ></el-super-search>
  13. <el-row :gutter="10" class="mb10" type="flex" justify="end" style="margin-top: 15px;">
  14. <el-col :span="1.5">
  15. <el-button type="primary" :size="size" plain @click="newAdd">新增</el-button>
  16. </el-col>
  17. <el-col :span="1.5">
  18. <el-button :size="size" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button type="primary" :size="size" plain
  22. @click="download('/system/apply/material/download',{},'申请单模板.xlsx')">模板下载
  23. </el-button>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button-group >
  27. <el-button :size="size" @click="handleImport">批量导入</el-button>
  28. <!-- <el-button
  29. :size="size"
  30. @click="handleDownload"
  31. v-hasPermi="['system:apply:export']"
  32. >批量导出</el-button> -->
  33. <el-button :size="size" @click="handleBatchSubmit">批量提交</el-button>
  34. </el-button-group>
  35. </el-col>
  36. <!-- 导入弹窗 -->
  37. <el-dialog
  38. title="批量导入"
  39. :visible.sync="importData.show"
  40. width="35%"
  41. center
  42. :before-close="handlefileDialogColse"
  43. >
  44. <div class="mb-import">
  45. <el-upload
  46. accept=".xls, .xlsx"
  47. ref="upload"
  48. action="#"
  49. :on-remove="handleFileRemove"
  50. :file-list="importData.list"
  51. :auto-upload="false"
  52. :on-change="handleChangeFile"
  53. :limit="1"
  54. style="text-align: center;"
  55. >
  56. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  57. <div slot="tip" class="el-upload__tip">只能上传Excel文件</div>
  58. </el-upload>
  59. </div>
  60. <span slot="footer">
  61. <el-button @click="handleImportData('cancal')">取 消</el-button>
  62. <el-button type="primary" @click="handleImportData('confirm')">确 定</el-button>
  63. </span>
  64. </el-dialog>
  65. </el-row>
  66. <div style="height: 600px;display: flex;">
  67. <el-super-table
  68. v-model="tableList"
  69. :dict="dict"
  70. :columns="TableColumns"
  71. :size="size"
  72. pagination
  73. index
  74. checkbox
  75. convenitentOperation
  76. :page="pageStatus"
  77. @pagination="getList"
  78. @row-dblclick="check"
  79. @selection-change="handleSelectionChange"
  80. @select="handleSelect"
  81. >
  82. <el-table-column
  83. fixed="right"
  84. label="操作"
  85. align="center"
  86. width="180"
  87. >
  88. <template slot-scope="scope">
  89. <el-button
  90. type="text"
  91. :size="size"
  92. @click.stop="check(scope.row)"
  93. >查看</el-button>
  94. <el-button
  95. @click.stop="edit(scope.row)"
  96. v-if="scope.row.status == 0 || scope.row.status == 3"
  97. type="text"
  98. :size="size"
  99. >编辑</el-button>
  100. <el-button
  101. @click.stop="jumpFlow(scope.row)"
  102. v-if="scope.row.oaId && scope.row.oaId !=''"
  103. type="text"
  104. :size="size"
  105. >流程跳转</el-button>
  106. <el-button
  107. type="text"
  108. :size="size"
  109. @click.stop="deleteRow(scope.row)"
  110. v-if="scope.row.status == 0 || scope.row.status == 3"
  111. >删除</el-button>
  112. <el-button
  113. v-if="scope.row.status == '1'"
  114. type="text"
  115. size="mini"
  116. @click.stop="handleBack(scope.row)"
  117. >流程收回</el-button>
  118. </template>
  119. </el-table-column>
  120. </el-super-table>
  121. </div>
  122. </el-card>
  123. </div>
  124. <component
  125. :is="isComponent"
  126. v-model="isList"
  127. :pageStu="page"
  128. :disable="disable"
  129. :row="rowDetail"
  130. @refresh="getList"
  131. v-if="!isList
  132. "/>
  133. </div>
  134. </template>
  135. <script>
  136. import addReq from './add.vue';
  137. import {getReqList, delReq, importData, fileImport,betchSubmit,toOA,oaBack} from '@/api/requisition/basic';
  138. import {saveAs} from "file-saver";
  139. import { blobValidate } from "@/utils/ruoyi";
  140. import { SearchColumns, TableColumns } from './columns';
  141. import { initDicts } from "@/utils/init.js";
  142. export default {
  143. name: 'requisition',
  144. dicts:[...initDicts([...SearchColumns,...TableColumns])],
  145. components: {
  146. addReq,
  147. ElSuperTable: () => import("@/components/super-table/index.vue"),
  148. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  149. },
  150. data() {
  151. const params = this.$init.params(SearchColumns);
  152. return {
  153. failLoad: false,
  154. tableList: [],
  155. size:'mini',
  156. params:params,
  157. SearchColumns:SearchColumns,
  158. TableColumns:TableColumns,
  159. pageStatus: { pageNum: 1, pageSize: 50, total: 0 },
  160. queryParams: {
  161. billCode: '',
  162. name: '',
  163. status: '',
  164. pageNum: 1,
  165. pageSize: 10
  166. },
  167. options: [{
  168. value: 0, label: '未提交'
  169. }, {
  170. value: 1, label: '审批中'
  171. }, {
  172. value: 2, label: '已完成'
  173. }, {
  174. value: 3, label: '已驳回'
  175. },],
  176. total: 0,
  177. // isComponent
  178. isComponent: 'addReq',
  179. isList: true,
  180. // 页面状态
  181. page: '',
  182. rowDetail: {},
  183. disable: false,
  184. checkedList: [],
  185. importData: {
  186. show: false,
  187. list: []
  188. },
  189. }
  190. },
  191. created() {
  192. },
  193. mounted() {
  194. this.params.billCode = this.$route.query.billCode
  195. this.getList(this.queryParams)
  196. },
  197. methods: {
  198. // 操作提示弹窗
  199. handleConfirmTips(success){
  200. this.$confirm('是否继续此操作?', '提示', {
  201. confirmButtonText: '确定',
  202. cancelButtonText: '取消',
  203. type: 'warning'
  204. }).then(() => {
  205. success();
  206. }).catch(() => {
  207. });
  208. },
  209. // 批量提交
  210. async handleBatchSubmit(){
  211. let filterList = this.checkedList.filter(item => !(item.status === '0' || item.status === '3') )
  212. console.log(filterList,'filterList',this.checkedList.length);
  213. if(!filterList.length && this.checkedList.length){
  214. this.handleConfirmTips(async() =>{
  215. try {
  216. this.failLoad = true;
  217. let ids = this.checkedList.map( item => Number(item.id));
  218. let {code,msg} = await betchSubmit({ids});
  219. if(code == 200){
  220. this.reset();
  221. }
  222. this.$notify({
  223. title: code == 200 ? msg : 'error',
  224. type: code == 200 ? 'success' :'error',
  225. message: code == 200 ?'' :msg,
  226. });
  227. } catch (error) {
  228. }finally{
  229. this.failLoad = false;
  230. }
  231. })
  232. }else{
  233. this.$notify.warning({
  234. title: '警告',
  235. message: '存在不符合提交条件数据或未选择数据!',
  236. });
  237. }
  238. },
  239. async jumpFlow (row){
  240. const {name} = this.$store.state.user;
  241. try {
  242. let {code,msg,oaUrl} = await toOA(name,row.oaId);
  243. if(code == 200){
  244. window.open(oaUrl)
  245. }
  246. } catch (error) {
  247. }finally{
  248. }
  249. },
  250. reset() {
  251. // this.queryParams.billCode = ''
  252. // this.queryParams.name = ''
  253. // this.queryParams.status = ''
  254. // this.queryParams.pageNum = 1
  255. this.pageStatus.pageNum = 1;
  256. this.pageStatus.pageSize = 10;
  257. this.params = this.$init.params(SearchColumns);
  258. this.getList(this.queryParams)
  259. },
  260. newAdd() {
  261. this.isList = false
  262. this.isComponent = 'addReq'
  263. this.page = 'add'
  264. this.disable = false
  265. },
  266. // 复制
  267. handleCopy() {
  268. this.isList = false;
  269. this.isComponent = 'addReq';
  270. this.page = 'copy';
  271. this.rowDetail = this.checkedList[0];
  272. this.disable = false;
  273. },
  274. // 导入
  275. handleImport() {
  276. this.importData.show = true
  277. },
  278. // 导出
  279. handleDownload(){
  280. let params = {
  281. ...this.params
  282. };
  283. this.download('/system/apply/material/export', {...params}, `物料申请单${new Date().getTime()}.xlsx`);
  284. },
  285. // 删除文件
  286. handleFileRemove(file, fileList) {
  287. // console.log('删除文件', file, 'file', fileList, 'fileList');
  288. this.importData.list = fileList;
  289. },
  290. // 文件发生改变
  291. handleChangeFile(file, fileList) {
  292. this.importData.list = fileList;
  293. },
  294. // 导入弹窗操作
  295. handleImportData(type) {
  296. switch (type) {
  297. // 取消
  298. case 'cancal':
  299. this.importData.list = [];
  300. this.importData.show = false;
  301. break;
  302. // 确认
  303. case 'confirm':
  304. if (this.importData.list.length) {
  305. let formData = new FormData();
  306. formData.append('file', this.importData.list[0].raw);
  307. importData(formData).then(res => {
  308. if (res.code == 200) {
  309. this.importData.show = false;
  310. this.importData.list = [];
  311. if (res.data.flag) {
  312. this.failLoad = true;
  313. // console.log(res.data.datas)
  314. let param = {failDatas: res.data.datas}
  315. if (null != param) {
  316. fileImport(param).then(res => {
  317. console.log('res',res)
  318. const isBlob = blobValidate(res);
  319. if (isBlob) {
  320. const blob = new Blob([res]);
  321. saveAs(blob, '导入失败的物料申请单数据.xlsx');
  322. }
  323. this.failLoad = false;
  324. this.reset();
  325. })
  326. }
  327. }
  328. this.$message({
  329. message: res.data.msg,
  330. type: res.data.flag ? 'warning' : 'success'
  331. });
  332. } else {
  333. this.$message({
  334. message: res.msg,
  335. type: res.code == 200 ? 'success' : 'warning'
  336. });
  337. }
  338. })
  339. } else {
  340. this.$message({
  341. message: '请上传文件之后在确认!',
  342. type: 'warning'
  343. });
  344. }
  345. break;
  346. }
  347. },
  348. handlefileDialogColse(done){
  349. this.importData.list = [];
  350. done();
  351. },
  352. // Select框
  353. handleSelect(selection, row) {
  354. this.checkedList = selection;
  355. // console.log(this.checkedList, 'this.checkedList');
  356. },
  357. getList(val) {
  358. // console.log('val', val)
  359. this.failLoad = true;
  360. getReqList({...this.params,...this.pageStatus}).then(res => {
  361. this.failLoad = false;
  362. if (res.code === 200) {
  363. this.tableList = res.rows;
  364. // this.total = res.total;
  365. this.pageStatus.total = res.total;
  366. }
  367. })
  368. // this.checkedList = [];
  369. },
  370. // 表格内状态栏判断值
  371. statusJug(row) {
  372. if (row.status == 0) {
  373. return '未提交'
  374. } else if (row.status == 1) {
  375. return '审批中'
  376. } else if (row.status == 2) {
  377. return '已完成'
  378. } else if (row.status == 3) {
  379. return '已驳回'
  380. }
  381. },
  382. //
  383. handleSelectionChange(selection) {
  384. this.checkedList = selection;
  385. },
  386. check(row) {
  387. // console.log('查看详情', row)
  388. this.isList = false
  389. this.isComponent = 'addReq'
  390. this.page = 'check'
  391. this.rowDetail = row
  392. this.disable = true
  393. },
  394. edit(row) {
  395. // console.log('修改先加载详情', row)
  396. this.isList = false
  397. this.isComponent = 'addReq'
  398. this.page = 'edit'
  399. this.rowDetail = row
  400. this.disable = false
  401. },
  402. commit(row) {
  403. // console.log('row', row)
  404. },
  405. deleteRow(row) {
  406. this.$confirm('是否删除此条数据?', '提示', {
  407. confirmButtonText: '确定',
  408. cancelButtonText: '取消',
  409. type: 'warning'
  410. }).then(() => {
  411. delReq(row.id).then(res => {
  412. if (res.code === 200) {
  413. this.$message({
  414. message: res.msg,
  415. type: 'success'
  416. });
  417. this.getList(this.queryParams)
  418. }
  419. })
  420. }).catch(() => {
  421. })
  422. },
  423. // handleSizeChange(val) {
  424. // console.log(`每页 ${val} 条`);
  425. // this.queryParams.pageSize = val
  426. // this.getList(this.queryParams)
  427. // },
  428. // handleCurrentChange(val) {
  429. // console.log(`当前页: ${val}`);
  430. // this.queryParams.pageNum = val
  431. // this.getList(this.queryParams)
  432. // }
  433. //流程收回
  434. async handleBack(row){
  435. try {
  436. const { msg, code } = await oaBack({
  437. fdTemplateId: process.env.NODE_ENV == "production" ?
  438. '1877e71c5a1929040faa0e647a2ac75e':'1873b5ce924f9cc37c06e884b1e9ee26',
  439. fdId: row.oaId,
  440. billCode: row.code,
  441. billMaker: row.createBy
  442. });
  443. if (code === 200) {
  444. this.$emit("success");
  445. this.$notify.success(msg);
  446. }
  447. } catch (err) {
  448. console.error(err);
  449. } finally {
  450. this.getList(this.queryParams);
  451. }
  452. },
  453. }
  454. }
  455. </script>
  456. <style scoped lang="scss">
  457. .requisition {
  458. // height: calc(100vh - 84px);
  459. padding: 12px;
  460. box-sizing: border-box;
  461. }
  462. </style>