index copy.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <div class="requisition" v-loading="failLoad">
  3. <div class="applyList" v-if="isList">
  4. <el-row :gutter="10" class="mb10">
  5. <el-col :span="1.5">
  6. <span style="font-size: 14px;margin-right: 5px;">单据编码</span>
  7. <el-input
  8. v-model="queryParams.billCode"
  9. size="small"
  10. placeholder="请输入单据编码查询"
  11. clearable
  12. style="width: 240px"
  13. />
  14. </el-col>
  15. <el-col :span="1.5">
  16. <span style="font-size: 14px;margin-right: 5px;">物料名称</span>
  17. <el-input
  18. v-model="queryParams.name"
  19. size="small"
  20. placeholder="请输入物料名称查询"
  21. clearable
  22. style="width: 240px"
  23. />
  24. </el-col>
  25. <el-col :span="1.5">
  26. <span style="font-size: 14px;margin-right: 5px;">单据状态</span>
  27. <el-select
  28. v-model="queryParams.status"
  29. size="small"
  30. placeholder="请选择单据状态"
  31. clearable
  32. style="width: 240px">
  33. <el-option
  34. v-for="item in options"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value">
  38. </el-option>
  39. </el-select>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-button type="primary" size="small" plain @click="getList(queryParams)">查询</el-button>
  43. </el-col>
  44. <!-- <el-col :span="1.5">
  45. <el-button type="primary" size="small" plain>高级查询</el-button>
  46. </el-col> -->
  47. <el-col :span="1.5">
  48. <el-button type="primary" size="small" plain @click="reset">重置</el-button>
  49. </el-col>
  50. </el-row>
  51. <el-row :gutter="10" class="mb10">
  52. <el-col :span="1.5">
  53. <el-button type="primary" size="small" plain @click="newAdd">新增</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button size="small" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button type="primary" size="small" plain
  60. @click="download('/system/apply/material/download',{},'申请单模板.xlsx')">模板下载
  61. </el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button size="small" @click="handleImport">批量导入</el-button>
  65. </el-col>
  66. <!-- 导入弹窗 -->
  67. <el-dialog
  68. title="批量导入"
  69. :visible.sync="importData.show"
  70. width="35%"
  71. center
  72. :before-close="handlefileDialogColse"
  73. >
  74. <div class="mb-import">
  75. <el-upload
  76. accept=".xls, .xlsx"
  77. ref="upload"
  78. action="#"
  79. :on-remove="handleFileRemove"
  80. :file-list="importData.list"
  81. :auto-upload="false"
  82. :on-change="handleChangeFile"
  83. :limit="1"
  84. style="text-align: center;"
  85. >
  86. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  87. <div slot="tip" class="el-upload__tip">只能上传Excel文件</div>
  88. </el-upload>
  89. </div>
  90. <span slot="footer">
  91. <el-button @click="handleImportData('cancal')">取 消</el-button>
  92. <el-button type="primary" @click="handleImportData('confirm')">确 定</el-button>
  93. </span>
  94. </el-dialog>
  95. <!-- <el-col :span="1.5">
  96. <el-button type="primary" size="small" plain>导入</el-button>
  97. </el-col>
  98. <el-col :span="1.5">
  99. <el-button type="primary" size="small" plain>导出</el-button>
  100. </el-col> -->
  101. <!-- <el-col :span="1.5">
  102. <el-button type="primary" size="small" plain>批量提交</el-button>
  103. </el-col>
  104. <el-col :span="1.5">
  105. <el-button type="primary" size="small" plain>批量删除</el-button>
  106. </el-col> -->
  107. </el-row>
  108. <el-card>
  109. <el-table
  110. :data="tableList"
  111. class="request-table"
  112. fit
  113. max-height="680"
  114. @selection-change="handleSelectionChange"
  115. @select="handleSelect"
  116. >
  117. <el-table-column type="selection" width="45"></el-table-column>
  118. <el-table-column label="序号" align="center" type="index" width="50"/>
  119. <el-table-column label="所属组织" align="center" width="200" prop="orgName"/>
  120. <el-table-column label="单据编码" align="center" width="200" prop="billCode"/>
  121. <el-table-column label="申请人" align="center" prop="createName"/>
  122. <el-table-column label="申请时间" align="center" width="150" prop="createTime"/>
  123. <el-table-column label="单据状态" align="center" prop="status" :formatter="statusJug"/>
  124. <!-- <el-table-column label="物料编码" align="center" width="150" prop="materialCode" /> -->
  125. <el-table-column label="物料名称" align="center" width="150" prop="name"/>
  126. <el-table-column label="创建人" align="center" prop="createName"/>
  127. <el-table-column label="创建时间" align="center" width="150" prop="createTime"/>
  128. <el-table-column label="最后修改人" align="center" width="120" prop="updateName"/>
  129. <el-table-column label="最后修改时间" align="center" width="150" prop="updateTime"/>
  130. <el-table-column
  131. fixed="right"
  132. label="操作"
  133. align="center"
  134. width="180"
  135. >
  136. <template slot-scope="scope">
  137. <el-button type="text" size="small" @click="check(scope.row)">查看</el-button>
  138. <el-button @click="edit(scope.row)" v-if="scope.row.status == 0 || scope.row.status == 3" type="text"
  139. size="small">编辑
  140. </el-button>
  141. <!-- <el-button @click="commit(scope.row)" v-if="scope.row.status == 0 || scope.row.status == 3" type="text" size="small">提交</el-button> -->
  142. <el-button type="text" size="small" @click="deleteRow(scope.row)"
  143. v-if="scope.row.status == 0 || scope.row.status == 3">删除
  144. </el-button>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <el-pagination
  149. @size-change="handleSizeChange"
  150. @current-change="handleCurrentChange"
  151. :page-sizes="[5, 10, 15, 20]"
  152. :page-size=queryParams.pageSize
  153. layout="total, sizes, prev, pager, next, jumper"
  154. :total="total"
  155. style="text-align: center;">
  156. </el-pagination>
  157. </el-card>
  158. </div>
  159. <component :is="isComponent" v-model="isList" :pageStu="page" :disable="disable" :row="rowDetail" @refresh="getList"
  160. v-if="!isList"/>
  161. </div>
  162. </template>
  163. <script>
  164. import addReq from './add.vue';
  165. import {getReqList, delReq, importData, fileImport} from '@/api/requisition/basic';
  166. import {saveAs} from "file-saver";
  167. import { blobValidate } from "@/utils/ruoyi";
  168. export default {
  169. name: 'requisition',
  170. components: {
  171. addReq
  172. },
  173. data() {
  174. return {
  175. failLoad: false,
  176. tableList: [],
  177. queryParams: {
  178. billCode: '',
  179. name: '',
  180. status: '',
  181. pageNum: 1,
  182. pageSize: 10
  183. },
  184. options: [{
  185. value: 0, label: '未提交'
  186. }, {
  187. value: 1, label: '审批中'
  188. }, {
  189. value: 2, label: '已完成'
  190. }, {
  191. value: 3, label: '已驳回'
  192. },],
  193. total: 0,
  194. // isComponent
  195. isComponent: 'addReq',
  196. isList: true,
  197. // 页面状态
  198. page: '',
  199. rowDetail: {},
  200. disable: false,
  201. checkedList: [],
  202. importData: {
  203. show: false,
  204. list: []
  205. },
  206. }
  207. },
  208. created() {
  209. },
  210. mounted() {
  211. this.getList(this.queryParams)
  212. },
  213. methods: {
  214. reset() {
  215. this.queryParams.billCode = ''
  216. this.queryParams.name = ''
  217. this.queryParams.status = ''
  218. this.queryParams.pageNum = 1
  219. this.getList(this.queryParams)
  220. },
  221. newAdd() {
  222. this.isList = false
  223. this.isComponent = 'addReq'
  224. this.page = 'add'
  225. this.disable = false
  226. },
  227. // 复制
  228. handleCopy() {
  229. this.isList = false;
  230. this.isComponent = 'addReq';
  231. this.page = 'copy';
  232. this.rowDetail = this.checkedList[0];
  233. this.disable = false;
  234. },
  235. // 导入
  236. handleImport() {
  237. this.importData.show = true
  238. },
  239. // 删除文件
  240. handleFileRemove(file, fileList) {
  241. console.log('删除文件', file, 'file', fileList, 'fileList');
  242. this.importData.list = fileList;
  243. },
  244. // 文件发生改变
  245. handleChangeFile(file, fileList) {
  246. this.importData.list = fileList;
  247. },
  248. // 导入弹窗操作
  249. handleImportData(type) {
  250. switch (type) {
  251. // 取消
  252. case 'cancal':
  253. this.importData.list = [];
  254. this.importData.show = false;
  255. break;
  256. // 确认
  257. case 'confirm':
  258. if (this.importData.list.length) {
  259. let formData = new FormData();
  260. formData.append('file', this.importData.list[0].raw);
  261. importData(formData).then(res => {
  262. if (res.code == 200) {
  263. this.importData.show = false;
  264. this.importData.list = [];
  265. if (res.data.flag) {
  266. this.failLoad = true;
  267. console.log(res.data.datas)
  268. let param = {failDatas: res.data.datas}
  269. if (null != param) {
  270. fileImport(param).then(res => {
  271. console.log('res',res)
  272. const isBlob = blobValidate(res);
  273. if (isBlob) {
  274. const blob = new Blob([res]);
  275. saveAs(blob, '导入失败的物料申请单数据.xlsx');
  276. }
  277. this.failLoad = false;
  278. })
  279. }
  280. }
  281. this.$message({
  282. message: res.data.msg,
  283. type: res.data.flag ? 'warning' : 'success'
  284. });
  285. } else {
  286. this.$message({
  287. message: res.msg,
  288. type: res.code == 200 ? 'success' : 'warning'
  289. });
  290. }
  291. })
  292. } else {
  293. this.$message({
  294. message: '请上传文件之后在确认!',
  295. type: 'warning'
  296. });
  297. }
  298. break;
  299. }
  300. },
  301. handlefileDialogColse(done){
  302. this.importData.list = [];
  303. done();
  304. },
  305. // Select框
  306. handleSelect(selection, row) {
  307. this.checkedList = selection;
  308. console.log(this.checkedList, 'this.checkedList');
  309. },
  310. getList(val) {
  311. console.log('val', val)
  312. getReqList(val).then(res => {
  313. if (res.code === 200) {
  314. this.tableList = res.rows
  315. this.total = res.total
  316. }
  317. })
  318. this.checkedList = [];
  319. },
  320. // 表格内状态栏判断值
  321. statusJug(row) {
  322. if (row.status == 0) {
  323. return '未提交'
  324. } else if (row.status == 1) {
  325. return '审批中'
  326. } else if (row.status == 2) {
  327. return '已完成'
  328. } else if (row.status == 3) {
  329. return '已驳回'
  330. }
  331. },
  332. //
  333. handleSelectionChange() {
  334. },
  335. check(row) {
  336. console.log('查看详情', row)
  337. this.isList = false
  338. this.isComponent = 'addReq'
  339. this.page = 'check'
  340. this.rowDetail = row
  341. this.disable = true
  342. },
  343. edit(row) {
  344. console.log('修改先加载详情', row)
  345. this.isList = false
  346. this.isComponent = 'addReq'
  347. this.page = 'edit'
  348. this.rowDetail = row
  349. this.disable = false
  350. },
  351. commit(row) {
  352. console.log('row', row)
  353. },
  354. deleteRow(row) {
  355. this.$confirm('是否删除此条数据?', '提示', {
  356. confirmButtonText: '确定',
  357. cancelButtonText: '取消',
  358. type: 'warning'
  359. }).then(() => {
  360. delReq(row.id).then(res => {
  361. if (res.code === 200) {
  362. this.$message({
  363. message: res.msg,
  364. type: 'success'
  365. });
  366. this.getList(this.queryParams)
  367. }
  368. })
  369. }).catch(() => {
  370. })
  371. },
  372. handleSizeChange(val) {
  373. console.log(`每页 ${val} 条`);
  374. this.queryParams.pageSize = val
  375. this.getList(this.queryParams)
  376. },
  377. handleCurrentChange(val) {
  378. console.log(`当前页: ${val}`);
  379. this.queryParams.pageNum = val
  380. this.getList(this.queryParams)
  381. }
  382. }
  383. }
  384. </script>
  385. <style scoped lang="scss">
  386. .requisition {
  387. height: calc(100vh - 84px);
  388. padding: 12px;
  389. box-sizing: border-box;
  390. }
  391. </style>