index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <template>
  2. <div id="PurchaseDemandList">
  3. <div v-if="isList">
  4. <el-form class="search_area" label-width="100px">
  5. <el-row :gutter="10">
  6. <el-col :span="1.5">
  7. <el-form-item label="单据编码">
  8. <el-input
  9. v-model.trim="queryParams.code"
  10. size="small"
  11. clearable
  12. style="width: 200px"
  13. />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="1.5">
  17. <el-form-item label="需求客户">
  18. <el-select clearable size="small" v-model="queryParams.customer" @focus="chooseOrg('CUSTOMER_PARAM', true, '选择客户')" style="width: 200px">
  19. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
  20. </el-select>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-form-item label="是否客户指定">
  25. <el-select clearable v-model="queryParams.isProcess" size="small" style="width: 200px" clearable placeholder="请选择">
  26. <el-option
  27. v-for="item in options"
  28. :key="item.value"
  29. :label="item.label"
  30. :value="item.value">
  31. </el-option>
  32. </el-select>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-form-item label="" label-width="20px">
  37. <el-button type="primary" size="small" icon="el-icon-search" plain @click="searchList">搜索</el-button>
  38. <el-button size="small" icon="el-icon-refresh" plain @click="resetList">重置</el-button>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <CollapseTransition>
  43. <div v-show="expanded">
  44. <el-row :gutter="10">
  45. <el-col :span="1.5">
  46. <el-form-item label="需求人员">
  47. <el-select clearable size="small" v-model="queryParams.demandPersonal" @focus="chooseOrg('CONTACTS_PARAM', true, '需求人员')" style="width: 200px">
  48. <el-option v-for="item in personOptions" :key="item.id" :label="item.name" :value="item.id" />
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-form-item label="单据来源">
  54. <el-select clearable v-model="queryParams.source" size="small" style="width: 200px">
  55. <el-option v-for="dict in dict.type.sys_bill_source" :key="dict.value" :label="dict.label" :value="dict.value">
  56. </el-option>
  57. </el-select>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-form-item label="业务类型">
  62. <el-select clearable v-model="queryParams.billType" size="small" style="width: 200px">
  63. <el-option v-for=" dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. </el-col>
  68. </el-row>
  69. <el-row :gutter="10">
  70. <el-col :span="1.5">
  71. <el-form-item label="需求部门">
  72. <el-select clearable v-model="queryParams.demandDept" size="small" :disabled="disable" @focus="chooseOrg('DEPT_PARAM', true, '需求部门')" style="width: 200px">
  73. <el-option
  74. v-for="item in deptOptions"
  75. :key="item.id"
  76. :label="item.name"
  77. :value="item.id">
  78. </el-option>
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="1.5">
  83. <el-form-item label="需求日期">
  84. <el-date-picker
  85. v-model="queryParams.demandDate"
  86. type="date"
  87. clearable
  88. value-format="yyyy-MM-dd"
  89. size="small"
  90. style="width: 200px"
  91. >
  92. </el-date-picker>
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-form-item label="审批结束日期">
  97. <el-date-picker
  98. v-model="queryParams.approverFinishTime"
  99. type="date"
  100. clearable
  101. value-format="yyyy-MM-dd"
  102. size="small"
  103. style="width: 200px"
  104. >
  105. </el-date-picker>
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row :gutter="10">
  110. <el-col :span="1.5">
  111. <el-form-item label="备注">
  112. <el-input
  113. v-model.trim="queryParams.remark"
  114. size="small"
  115. clearable
  116. style="width: 200px"
  117. />
  118. </el-form-item>
  119. </el-col>
  120. </el-row>
  121. </div>
  122. </CollapseTransition>
  123. </el-form>
  124. <el-divider class="lines"><i style="cursor: pointer;" :class="expanded?'el-icon-arrow-up':'el-icon-arrow-down'" @click="drop"></i></el-divider>
  125. <el-card>
  126. <div class="btn_grooup">
  127. <el-button type="primary" size="small" @click="addDivision">新增</el-button>
  128. <el-dropdown size="small" @command="handleCommand">
  129. <el-button size="small" type="primary" style="margin-left: 10px;">
  130. 导入<i class="el-icon-arrow-down el-icon--right"></i>
  131. </el-button>
  132. <el-dropdown-menu slot="dropdown">
  133. <el-dropdown-item command="数据导入">数据导入</el-dropdown-item>
  134. <el-dropdown-item command="模板下载">模板下载</el-dropdown-item>
  135. </el-dropdown-menu>
  136. </el-dropdown>
  137. <el-dropdown size="small" @command="handleExport">
  138. <el-button size="small" type="primary" style="margin: 0 10px;">
  139. 导出<i class="el-icon-arrow-down el-icon--right"></i>
  140. </el-button>
  141. <el-dropdown-menu slot="dropdown">
  142. <el-dropdown-item command="选中导出">选中导出</el-dropdown-item>
  143. <el-dropdown-item command="全部导出">全部导出</el-dropdown-item>
  144. </el-dropdown-menu>
  145. </el-dropdown>
  146. <el-button type="primary" size="small" @click="delItems">删除</el-button>
  147. <!-- <el-button type="primary" size="small">打印</el-button> -->
  148. </div>
  149. <el-table
  150. :data="tableList"
  151. fit
  152. max-height="350"
  153. @selection-change="handleSelectionChange"
  154. >
  155. <el-table-column show-overflow-tooltip type="selection" width="55" />
  156. <el-table-column show-overflow-tooltip label="编码" align="center" width="200" prop="code"/>
  157. <el-table-column show-overflow-tooltip label="需求日期" align="center" width="120" prop="demandDate"/>
  158. <el-table-column show-overflow-tooltip label="审批结束日期" align="center" width="150" prop="approverFinishTime"/>
  159. <el-table-column show-overflow-tooltip label="单据状态" align="center" prop="satus" :formatter="formatterStatus"/>
  160. <!-- <el-table-column show-overflow-tooltip label="是否已处理需求" align="center" width="150" prop="isProcess" /> -->
  161. <el-table-column show-overflow-tooltip label="业务类型" align="center" prop="billType" :formatter="formatterBillType"/>
  162. <!-- <el-table-column show-overflow-tooltip label="是否特殊需求" align="center" width="150" prop="isSpeical" /> -->
  163. <el-table-column show-overflow-tooltip label="需求人员" align="center" prop="demandPersonalName" />
  164. <el-table-column show-overflow-tooltip label="需求客户" align="center" prop="customerName" width="150"/>
  165. <el-table-column show-overflow-tooltip label="需求部门" align="center" prop="demandDeptName" width="150"/>
  166. <!-- <el-table-column show-overflow-tooltip label="供应仓库" align="center" width="120" prop="warehouseName" /> -->
  167. <!-- <el-table-column show-overflow-tooltip label="供应货位" align="center" width="150" prop="goodsAllocationName" /> -->
  168. <el-table-column show-overflow-tooltip label="单据来源" align="center" prop="source" width="120" :formatter="formatterSource"/>
  169. <el-table-column show-overflow-tooltip label="组织" align="center" width="200" prop="orgName"/>
  170. <el-table-column show-overflow-tooltip label="备注" align="center" width="150" prop="remark" />
  171. <el-table-column
  172. fixed="right"
  173. label="操作"
  174. align="center"
  175. width="150"
  176. >
  177. <template slot-scope="scope">
  178. <el-button type="text" size="small" @click="check(scope.row)">查看</el-button>
  179. <el-button type="text" size="small" v-if="scope.row.status == '0' || scope.row.status == '3'" @click="edit(scope.row)">编辑</el-button>
  180. <el-button type="text" size="small" v-if="scope.row.status == '0' || scope.row.status == '3'" @click="deleteids(scope.row)">删除</el-button>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <el-pagination
  185. @size-change="handleSizeChange"
  186. @current-change="handleCurrentChange"
  187. :current-page="1"
  188. :page-sizes="[5, 10, 15, 20]"
  189. :page-size="100"
  190. layout="total, sizes, prev, pager, next, jumper"
  191. :total=total>
  192. </el-pagination>
  193. </el-card>
  194. </div>
  195. <!-- 用户导入对话框 -->
  196. <el-dialog title="数据导入" :visible.sync="upload.open" width="400px">
  197. <el-upload
  198. ref="upload"
  199. :limit="1"
  200. accept=".xlsx, .xls"
  201. :headers="upload.headers"
  202. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  203. :disabled="upload.isUploading"
  204. :on-progress="handleFileUploadProgress"
  205. :on-success="handleFileSuccess"
  206. :on-error="errorFile"
  207. :auto-upload="false"
  208. drag
  209. >
  210. <i class="el-icon-upload"></i>
  211. <div class="el-upload__text">
  212. 将文件拖到此处,或
  213. <em>点击上传</em>
  214. </div>
  215. <!-- <div class="el-upload__tip" slot="tip">
  216. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  217. </div> -->
  218. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  219. </el-upload>
  220. <div slot="footer" class="dialog-footer">
  221. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  222. <el-button @click="upload.open = false">取 消</el-button>
  223. </div>
  224. </el-dialog>
  225. <Add v-model="isList" v-if="!isList" :pageStu="page" :disable="disable" :row="rowDetail" @refresh="resetList"/>
  226. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  227. </div>
  228. </template>
  229. <script>
  230. // 导入的token
  231. import { getToken } from "@/utils/auth";
  232. import Add from './add.vue'
  233. import Refers from '@/components/Refers/refers.vue'
  234. import CollapseTransition from '@/components/MyCollapse/collapse.vue'
  235. import {getDemandList, delDemand, downLoadDemand, exportDemand } from '@/api/purchase/purchaseDemand.js'
  236. export default {
  237. name: 'PurchaseDemandList',
  238. components: {
  239. Add,
  240. CollapseTransition,
  241. Refers
  242. },
  243. dicts: ['sys_processing_mode', 'sys_status', 'sys_bill_source', 'sys_business', 'sys_reserve_ratio', 'sys_period_unit', 'sys_price_type'],
  244. data() {
  245. return {
  246. // 导入参数
  247. upload: {
  248. // 是否显示弹出层(导入)
  249. open: false,
  250. // 弹出层标题(导入)
  251. title: "数据导入",
  252. // 是否禁用上传
  253. isUploading: false,
  254. // 是否更新已经存在的用户数据
  255. updateSupport: 1,
  256. // 设置上传的请求头部
  257. headers: { Authorization: "Bearer " + getToken() },
  258. // 上传的地址
  259. url: process.env.VUE_APP_BASE_API + "/pu/demand/import"
  260. },
  261. // 下拉收起配置
  262. expanded: false,
  263. // 页面配置
  264. isList: true,
  265. // 页面状态
  266. page: '',
  267. queryParams: {
  268. code: '',
  269. customer: '',
  270. isProcess: '',
  271. demandPersonal: '',
  272. source: '',
  273. billType: '',
  274. demandDept: '',
  275. demandDate: '',
  276. approverFinishTime: '',
  277. remark: '',
  278. pageNum: 1,
  279. pageSize: 5
  280. },
  281. referCondition: {
  282. type: '',
  283. isPage: true,
  284. title: ''
  285. },
  286. options: [{
  287. value: 'Y', label: '是',
  288. }, {
  289. value: 'N', label: '否'
  290. }],
  291. customerOptions: [],
  292. personOptions: [],
  293. deptOptions: [],
  294. tableList: [],
  295. total: 0,
  296. rowDetail: {},
  297. disable: false,
  298. ids: []
  299. }
  300. },
  301. created() {
  302. this.getList(this.queryParams)
  303. },
  304. methods: {
  305. // 格式化表格内容
  306. formatterStatus(row) {
  307. switch(row.status){
  308. case '0':
  309. return '未提交'
  310. case '1':
  311. return '审批中'
  312. case '2':
  313. return '已完成'
  314. case '3':
  315. return '已驳回'
  316. }
  317. },
  318. formatterBillType(row) {
  319. switch (row.billType) {
  320. case 'ZQBH':
  321. return '周期备货'
  322. case 'FXXQ':
  323. return '分销需求'
  324. case 'TSXQ':
  325. return '特殊采购需求'
  326. case 'BDXQ':
  327. return '补单需求'
  328. case 'JJXQ':
  329. return '紧急需求单'
  330. case 'XPXQ':
  331. return '新品需求'
  332. case 'HZBM':
  333. return '合作部门需求'
  334. }
  335. },
  336. formatterSource(row) {
  337. switch (row.source) {
  338. case '1':
  339. return '手工导入'
  340. case '2':
  341. return '按客户计算'
  342. case '3':
  343. return '按仓库计算'
  344. case '4':
  345. return '手工新增'
  346. }
  347. },
  348. searchList() {
  349. this.getList(this.queryParams)
  350. },
  351. resetList() {
  352. this.queryParams = {
  353. code: '',
  354. customer: '',
  355. isProcess: '',
  356. demandPersonal: '',
  357. source: '',
  358. billType: '',
  359. demandDept: '',
  360. demandDate: '',
  361. remark: '',
  362. pageNum: 1,
  363. pageSize: 5
  364. }
  365. this.getList(this.queryParams)
  366. },
  367. getList(params){
  368. getDemandList(params).then(res => {
  369. if (res.code === 200) {
  370. this.tableList = res.rows
  371. this.total = res.total
  372. }
  373. })
  374. },
  375. handleSelectionChange(selection) {
  376. console.log('选中', selection)
  377. this.ids = selection.map(item => item.id)
  378. console.log('选中数组', this.ids.join())
  379. },
  380. handleCommand(command) {
  381. // alert(command)
  382. if(command == '模板下载') {
  383. downLoadDemand({}).then(res => {
  384. console.log('下载的文件流', res)
  385. const blob = new Blob([res], {
  386. type: "application/vnd.ms-excel;charset=UTF-8",
  387. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  388. const downloadElement = document.createElement("a"); //创建a标签
  389. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  390. // var temp = res.headers["content-disposition"];
  391. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  392. // var name = fileName.split(";")[0]; //切割成文件名
  393. downloadElement.href = href; //下载地址
  394. downloadElement.download = '模板'; // 下载后文件名
  395. document.body.appendChild(downloadElement);
  396. downloadElement.click(); // 点击下载
  397. document.body.removeChild(downloadElement); // 下载完成移除元素
  398. window.URL.revokeObjectURL(href); // 释放blob对象
  399. })
  400. }
  401. if (command == '数据导入') {
  402. this.upload.title = "用户导入"
  403. this.upload.open = true
  404. }
  405. },
  406. // 文件上传中处理
  407. handleFileUploadProgress(event, file, fileList) {
  408. this.upload.isUploading = true;
  409. },
  410. // 文件上传成功处理
  411. handleFileSuccess(response, file, fileList) {
  412. this.upload.open = false;
  413. this.upload.isUploading = false;
  414. this.$refs.upload.clearFiles();
  415. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  416. this.getList(this.queryParams);
  417. },
  418. errorFile(err) {
  419. this.$modal.notifyError("文件已变动,请重新上传");
  420. },
  421. // 提交上传文件
  422. submitFileForm() {
  423. this.$refs.upload.submit();
  424. },
  425. handleExport(command) {
  426. if(command == '选中导出') {
  427. if (this.ids.length == 0) {
  428. this.$modal.msgWarning("请选中至少一条数据");
  429. } else {
  430. let param = {all: false, ids: this.ids}
  431. exportDemand(param).then(res => {
  432. const blob = new Blob([res], {
  433. type: "application/vnd.ms-excel;charset=UTF-8",
  434. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  435. const downloadElement = document.createElement("a"); //创建a标签
  436. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  437. // var temp = res.headers["content-disposition"];
  438. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  439. // var name = fileName.split(";")[0]; //切割成文件名
  440. downloadElement.href = href; //下载地址
  441. downloadElement.download = '选中导出'; // 下载后文件名
  442. document.body.appendChild(downloadElement);
  443. downloadElement.click(); // 点击下载
  444. document.body.removeChild(downloadElement); // 下载完成移除元素
  445. window.URL.revokeObjectURL(href); // 释放blob对象
  446. })
  447. }
  448. } else {
  449. let param2 = {all: true}
  450. exportDemand(param2).then(res => {
  451. const blob = new Blob([res], {
  452. type: "application/vnd.ms-excel;charset=UTF-8",
  453. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  454. const downloadElement = document.createElement("a"); //创建a标签
  455. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  456. // var temp = res.headers["content-disposition"];
  457. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  458. // var name = fileName.split(";")[0]; //切割成文件名
  459. downloadElement.href = href; //下载地址
  460. downloadElement.download = '全部导出'; // 下载后文件名
  461. document.body.appendChild(downloadElement);
  462. downloadElement.click(); // 点击下载
  463. document.body.removeChild(downloadElement); // 下载完成移除元素
  464. window.URL.revokeObjectURL(href); // 释放blob对象
  465. })
  466. }
  467. },
  468. addDivision() {
  469. this.isList = false
  470. this.page = 'add'
  471. this.disable = false
  472. },
  473. check(row) {
  474. this.isList = false
  475. this.page = 'check'
  476. this.rowDetail = row
  477. this.disable = true
  478. },
  479. edit(row) {
  480. this.isList = false
  481. this.page = 'edit'
  482. this.rowDetail = row
  483. this.disable = false
  484. },
  485. // 行内删除
  486. deleteids(row) {
  487. console.log('row', row)
  488. this.$modal.confirm('确定删除选择数据?').then(() => {
  489. delDemand(row.id).then(res => {
  490. if (res.code === 200) {
  491. this.$modal.msgSuccess("删除成功");
  492. this.getList(this.queryParams)
  493. }
  494. })
  495. }).catch(() => {})
  496. },
  497. // 批量删除按钮
  498. delItems() {
  499. if(this.ids.length == 0) {
  500. this.$modal.msgWarning("请选中至少一条数据");
  501. } else {
  502. let param = this.ids.join()
  503. this.$modal.confirm('确认信息').then(() => {
  504. delDemand(param).then(res => {
  505. if (res.code === 200) {
  506. this.$modal.msgSuccess("删除成功");
  507. this.getList(this.queryParams)
  508. }
  509. })
  510. }).catch(() => {})
  511. }
  512. },
  513. handleSizeChange(val) {
  514. console.log(`每页 ${val} 条`);
  515. this.queryParams.pageSize = val
  516. this.getList(this.queryParams)
  517. },
  518. handleCurrentChange(val) {
  519. console.log(`当前页: ${val}`);
  520. this.queryParams.pageNum = val
  521. this.getList(this.queryParams)
  522. },
  523. drop() {
  524. this.expanded = !this.expanded
  525. },
  526. // 搜索区参照选择
  527. chooseOrg(type, isPage, title) {
  528. this.referCondition.type = type
  529. this.referCondition.isPage = isPage
  530. this.referCondition.title = title
  531. this.$refs.refer.init(this.referCondition)
  532. },
  533. selectionsToInput(selection) {
  534. if (this.referCondition.type == 'CUSTOMER_PARAM') {
  535. this.customerOptions = selection
  536. this.queryParams.customer = selection[0].id
  537. }
  538. if (this.referCondition.type == 'CONTACTS_PARAM') {
  539. this.personOptions = selection
  540. this.queryParams.demandPersonal = selection[0].id
  541. }
  542. if (this.referCondition.type == 'DEPT_PARAM') {
  543. this.deptOptions = selection
  544. this.queryParams.demandDept = selection[0].id
  545. }
  546. }
  547. }
  548. }
  549. </script>
  550. <style lang="scss" scoped>
  551. #PurchaseDemandList {
  552. height: calc(100vh - 84px);
  553. padding: 12px;
  554. box-sizing: border-box;
  555. overflow-y: scroll;
  556. }
  557. .btn_grooup {
  558. margin-bottom: 10px;
  559. display: flex;
  560. justify-content: flex-end;
  561. }
  562. .lines {
  563. margin-top: 0;
  564. }
  565. </style>