index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. <template>
  2. <div id="PurchaseDemandList">
  3. <div v-if="isList">
  4. <el-card style="position: relative;">
  5. <el-form class="search_area" label-width="100px">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="需求单号">
  9. <el-input
  10. v-model.trim="queryParams.code"
  11. size="mini"
  12. clearable
  13. style="width: 200px"
  14. />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="1.5">
  18. <el-form-item label="需求客户">
  19. <el-select clearable size="mini" v-model="queryParams.customer" @focus="chooseOrg('CUSTOMER_PARAM', true, '需求客户')" style="width: 200px">
  20. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
  21. </el-select>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="1.5">
  25. <el-form-item label="是否客户指定">
  26. <el-select clearable v-model="queryParams.isCustomerSpecified" size="mini" style="width: 200px" placeholder="请选择">
  27. <el-option
  28. v-for="item in options"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-form-item label="需求人员">
  38. <el-select clearable size="mini" v-model="queryParams.demandPersonal" @focus="chooseOrg('CONTACTS_PARAM', true, '需求人员')" style="width: 200px">
  39. <el-option v-for="item in personOptions" :key="item.id" :label="item.name" :value="item.code" />
  40. </el-select>
  41. </el-form-item>
  42. </el-col>
  43. <!-- <el-col :span="1.5"> -->
  44. <!-- <el-form-item label="" label-width="20px"> -->
  45. <div style="position: absolute;top: 3px;right: 10px;">
  46. <el-button type="primary" size="mini" @click="searchList">搜索</el-button>
  47. <el-button size="mini" plain @click="resetList">重置</el-button>
  48. </div>
  49. <!-- </el-form-item> -->
  50. <!-- </el-col> -->
  51. </el-row>
  52. <CollapseTransition>
  53. <div v-show="expanded">
  54. <el-row :gutter="10">
  55. <el-col :span="1.5">
  56. <el-form-item label="单据来源">
  57. <el-select clearable v-model="queryParams.source" size="mini" style="width: 200px">
  58. <el-option v-for="dict in dict.type.sys_bill_source" :key="dict.value" :label="dict.label" :value="dict.value">
  59. </el-option>
  60. </el-select>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-form-item label="业务类型">
  65. <el-select clearable v-model="queryParams.billType" size="mini" style="width: 200px">
  66. <el-option v-for=" dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
  67. </el-option>
  68. </el-select>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-form-item label="需求部门">
  73. <el-select clearable v-model="queryParams.demandDept" size="mini" @focus="chooseOrg('DEPT_PARAM', true, '需求部门')" style="width: 200px">
  74. <el-option
  75. v-for="item in deptOptions"
  76. :key="item.id"
  77. :label="item.name"
  78. :value="item.id">
  79. </el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-form-item label="需求日期">
  85. <el-date-picker
  86. v-model="queryParams.demandDate"
  87. type="date"
  88. clearable
  89. value-format="yyyy-MM-dd"
  90. size="mini"
  91. style="width: 200px"
  92. >
  93. </el-date-picker>
  94. </el-form-item>
  95. </el-col>
  96. </el-row>
  97. <el-row :gutter="10">
  98. <el-col :span="1.5">
  99. <el-form-item label="物料编码">
  100. <el-input
  101. v-model.trim="queryParams.materialCode"
  102. size="mini"
  103. clearable
  104. style="width: 200px"
  105. />
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="1.5">
  109. <el-form-item label="单据状态">
  110. <el-select clearable v-model="queryParams.status" size="mini" style="width: 200px">
  111. <el-option v-for=" dict in dict.type.sys_status" :key="dict.value" :label="dict.label" :value="dict.value">
  112. </el-option>
  113. </el-select>
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="1.5">
  117. <el-form-item label="需求计划">
  118. <el-select clearable v-model="queryParams.planType" size="mini" style="width: 200px">
  119. <el-option v-for="dict in dict.type.sys_plan_type" :key="dict.value" :label="dict.label" :value="dict.value">
  120. </el-option>
  121. </el-select>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="1.5">
  125. <el-form-item label="备注">
  126. <el-input
  127. v-model.trim="queryParams.remark"
  128. size="mini"
  129. clearable
  130. style="width: 200px"
  131. />
  132. </el-form-item>
  133. </el-col>
  134. </el-row>
  135. </div>
  136. </CollapseTransition>
  137. </el-form>
  138. <el-divider class="lines"><i style="cursor: pointer;" :class="expanded?'el-icon-arrow-up':'el-icon-arrow-down'" @click="drop"></i></el-divider>
  139. <div class="btn_grooup">
  140. <el-button type="primary" size="mini" @click="addDivision">新增</el-button>
  141. <el-dropdown size="mini" @command="handleCommand">
  142. <el-button size="mini" type="primary" style="margin-left: 10px;">
  143. 导入<i class="el-icon-arrow-down el-icon--right"></i>
  144. </el-button>
  145. <el-dropdown-menu slot="dropdown">
  146. <el-dropdown-item command="数据导入">数据导入</el-dropdown-item>
  147. <el-dropdown-item command="模板下载">模板下载</el-dropdown-item>
  148. </el-dropdown-menu>
  149. </el-dropdown>
  150. <el-dropdown size="mini" @command="handleExport">
  151. <el-button size="mini" type="primary" style="margin: 0 10px;">
  152. 导出<i class="el-icon-arrow-down el-icon--right"></i>
  153. </el-button>
  154. <el-dropdown-menu slot="dropdown">
  155. <el-dropdown-item command="选中导出">选中导出</el-dropdown-item>
  156. <el-dropdown-item command="全部导出">全部导出</el-dropdown-item>
  157. </el-dropdown-menu>
  158. </el-dropdown>
  159. <el-button type="primary" size="mini" @click="delItems">删除</el-button>
  160. <!-- <el-button type="primary" size="mini">打印</el-button> -->
  161. </div>
  162. <el-table
  163. v-loading="loading"
  164. :data="tableList"
  165. fit
  166. :cell-style="{ borderColor: '#c0c0c0' }"
  167. :header-cell-style="{ borderColor: '#c0c0c0' }"
  168. class="exporttable"
  169. max-height="410"
  170. border
  171. highlight-current-row
  172. style="font-size: 12px;"
  173. @selection-change="handleSelectionChange"
  174. @row-click="rowSelect"
  175. @row-dblclick="doubleClick"
  176. ref="tables"
  177. >
  178. <el-table-column show-overflow-tooltip type="selection" width="55" fixed="left"/>
  179. <el-table-column show-overflow-tooltip label="序号" type="index" align="center" width="50px" fixed="left"/>
  180. <el-table-column show-overflow-tooltip label="需求单号" align="center" width="170" prop="code"/>
  181. <el-table-column show-overflow-tooltip label="需求日期" align="center" width="120" prop="demandDate"/>
  182. <el-table-column show-overflow-tooltip label="需求计划" align="center" width="120" prop="planType" :formatter="formatterPlanType"/>
  183. <el-table-column show-overflow-tooltip label="审批结束日期" align="center" width="120" prop="approverFinishTime"/>
  184. <el-table-column show-overflow-tooltip label="单据状态" align="center" prop="satus" :formatter="formatterStatus"/>
  185. <el-table-column show-overflow-tooltip label="业务类型" align="center" width="120" prop="billType" :formatter="formatterBillType"/>
  186. <!-- <el-table-column show-overflow-tooltip label="是否特殊需求" align="center" width="150" prop="isSpeical" /> -->
  187. <el-table-column show-overflow-tooltip label="需求人员" align="center" prop="demandPersonalName" />
  188. <el-table-column show-overflow-tooltip label="需求客户" align="center" prop="customerName" width="150"/>
  189. <el-table-column show-overflow-tooltip label="需求部门" align="center" prop="demandDeptName" width="150"/>
  190. <!-- <el-table-column show-overflow-tooltip label="供应仓库" align="center" width="120" prop="warehouseName" /> -->
  191. <!-- <el-table-column show-overflow-tooltip label="供应货位" align="center" width="150" prop="goodsAllocationName" /> -->
  192. <el-table-column show-overflow-tooltip label="单据来源" align="center" prop="source" width="120" :formatter="formatterSource"/>
  193. <el-table-column show-overflow-tooltip label="备注" align="center" width="150" prop="remark" />
  194. <el-table-column
  195. fixed="right"
  196. label="操作"
  197. align="center"
  198. width="180"
  199. >
  200. <template slot-scope="scope">
  201. <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button>
  202. <el-button type="text" size="mini" v-if="scope.row.status == '0' || scope.row.status == '3'" @click="edit(scope.row)">编辑</el-button>
  203. <el-button type="text" size="mini" v-if="scope.row.status == '0' || scope.row.status == '3'" @click="commit(scope.row)">提交</el-button>
  204. <el-button type="text" size="mini" v-if="scope.row.status == '1' && scope.row.flowId" @click="reback(scope.row)">收回</el-button>
  205. <el-button type="text" size="mini" v-if="scope.row.status == '0' || scope.row.status == '3'" @click="deleteids(scope.row)">删除</el-button>
  206. </template>
  207. </el-table-column>
  208. </el-table>
  209. <el-pagination
  210. background
  211. @size-change="handleSizeChange"
  212. @current-change="handleCurrentChange"
  213. :current-page="queryParams.pageNum"
  214. :page-sizes="[10, 20, 50, 100, 200, 500]"
  215. :page-size="100"
  216. layout="total, sizes, prev, pager, next, jumper"
  217. :total=total>
  218. </el-pagination>
  219. </el-card>
  220. </div>
  221. <!-- 用户导入对话框 -->
  222. <el-dialog title="数据导入" :visible.sync="upload.open" width="400px">
  223. <el-upload
  224. ref="upload"
  225. :limit="1"
  226. accept=".xlsx, .xls"
  227. :headers="upload.headers"
  228. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  229. :disabled="upload.isUploading"
  230. :on-progress="handleFileUploadProgress"
  231. :on-success="handleFileSuccess"
  232. :on-error="errorFile"
  233. :auto-upload="false"
  234. drag
  235. >
  236. <i class="el-icon-upload"></i>
  237. <div class="el-upload__text">
  238. 将文件拖到此处,或
  239. <em>点击上传</em>
  240. </div>
  241. <!-- <div class="el-upload__tip" slot="tip">
  242. <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
  243. </div> -->
  244. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  245. </el-upload>
  246. <div slot="footer">
  247. <el-button size="mini" type="primary" @click="submitFileForm">确 定</el-button>
  248. <el-button size="mini" @click="upload.open = false">取 消</el-button>
  249. </div>
  250. </el-dialog>
  251. <!-- 模板下载新增参数 -->
  252. <el-dialog title="需求模板下载" :visible.sync="download.open" @close="clearDownload" width="400px">
  253. <el-row style="margin-bottom: 20px;">
  254. <span style="margin-right: 10px;">需求计划</span>
  255. <el-select size="mini" v-model="download.planType">
  256. <el-option v-for="dict in dict.type.sys_plan_type" :key="dict.value" :label="dict.label" :value="dict.value">
  257. </el-option>
  258. </el-select>
  259. </el-row>
  260. <el-row style="margin-bottom: 20px;">
  261. <span style="margin-right: 10px;">需求客户</span>
  262. <el-select clearable size="mini" v-model="download.customer" @clear="download.customer = ''" @focus="chooseOrg('CUSTOMER_PARAM', true, '选择客户')">
  263. <el-option v-for="item in mBcustomer" :key="item.id" :label="item.name" :value="item.code" />
  264. </el-select>
  265. </el-row>
  266. <el-row style="margin-bottom: 20px;">
  267. <span style="margin-right: 10px;">供应仓库</span>
  268. <el-select clearable size="mini" v-model="download.warehouse" @clear="cleanMb" @focus="chooseOrg('WAREHOUSE_PARAM', true, '选择仓库')">
  269. <el-option v-for="item in mBwarehouse" :key="item.id" :label="item.name" :value="item.code" />
  270. </el-select>
  271. </el-row>
  272. <el-row style="margin-bottom: 20px;">
  273. <span style="margin-right: 10px;">供应货位</span>
  274. <el-select clearable size="mini" v-model="download.cargoSpace" @clear="download.cargoSpace = ''" @focus="mbHuowei('ALLOCATION_PARAM', true, '选择货位', download.warehouseId)">
  275. <el-option v-for="item in mBcargoSpace" :key="item.id" :label="item.name" :value="item.code" />
  276. </el-select>
  277. </el-row>
  278. <el-row style="margin-bottom: 20px;">
  279. <span style="margin-right: 10px;">品类选择</span>
  280. <el-select
  281. v-model="download.category"
  282. size="mini"
  283. clearable
  284. @focus="chooseTreeRefer('MATERIALCLASSIFY_PARAM', false, '选择品类')"
  285. >
  286. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.code" />
  287. </el-select>
  288. </el-row>
  289. <div slot="footer">
  290. <el-button size="mini" type="primary" @click="mbDownload">模板下载</el-button>
  291. <el-button size="mini" @click="download.open = false">取 消</el-button>
  292. </div>
  293. </el-dialog>
  294. <Add v-model="isList" v-if="!isList" :pageStu="page" :disable="disable" :row="rowDetail" @refresh="searchList"/>
  295. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  296. <TreeRefers ref="tree" @doSubmit="selectionsToInput2" :single="true"/>
  297. </div>
  298. </template>
  299. <script>
  300. // 导入的token
  301. import { getToken } from "@/utils/auth";
  302. import Add from './add.vue'
  303. import Refers from '@/components/Refers/refers.vue'
  304. import TreeRefers from '@/components/Refers/treeRefer.vue'
  305. import CollapseTransition from '@/components/MyCollapse/collapse.vue'
  306. // 流程收回
  307. import { rebacktWork } from '@/api/purchase/workSpace.js'
  308. import {getDemandList, delDemand, downLoadDemand, exportDemand, submitDemand } from '@/api/purchase/purchaseDemand.js'
  309. export default {
  310. name: 'PurchaseDemandList',
  311. components: {
  312. Add,
  313. CollapseTransition,
  314. Refers,
  315. TreeRefers
  316. },
  317. dicts: ['sys_processing_mode', 'sys_status', 'sys_bill_source', 'sys_business', 'sys_reserve_ratio', 'sys_period_unit', 'sys_price_type', 'sys_plan_type'],
  318. data() {
  319. return {
  320. loading: true,
  321. // 导入参数
  322. upload: {
  323. // 是否显示弹出层(导入)
  324. open: false,
  325. // 弹出层标题(导入)
  326. title: "数据导入",
  327. // 是否禁用上传
  328. isUploading: false,
  329. // 是否更新已经存在的用户数据
  330. updateSupport: 1,
  331. // 设置上传的请求头部
  332. headers: { Authorization: "Bearer " + getToken() },
  333. // 上传的地址
  334. url: process.env.VUE_APP_BASE_API + "/pu/demand/import"
  335. },
  336. // 模板下载参数
  337. download: {
  338. open: false,
  339. planType: 'ZJH',
  340. customer: '',
  341. warehouse: '',
  342. warehouseId: '',
  343. cargoSpace: '',
  344. category: ''
  345. },
  346. mBcustomer: [],
  347. mBwarehouse: [],
  348. mBcargoSpace: [],
  349. classOptions: [],
  350. // 下拉收起配置
  351. expanded: false,
  352. // 页面配置
  353. isList: true,
  354. // 页面状态
  355. page: '',
  356. queryParams: {
  357. code: this.$route.query.billCode,
  358. customer: '',
  359. isCustomerSpecified: '',
  360. demandPersonal: '',
  361. source: '',
  362. planType: '',
  363. billType: '',
  364. demandDept: '',
  365. demandDate: '',
  366. remark: '',
  367. materialCode: '',
  368. status: '',
  369. pageNum: 1,
  370. pageSize: 100
  371. },
  372. referCondition: {
  373. type: '',
  374. isPage: true,
  375. title: ''
  376. },
  377. options: [{
  378. value: 'Y', label: '是',
  379. }, {
  380. value: 'N', label: '否'
  381. }],
  382. customerOptions: [],
  383. personOptions: [],
  384. deptOptions: [],
  385. tableList: [],
  386. total: 0,
  387. rowDetail: {},
  388. disable: false,
  389. ids: []
  390. }
  391. },
  392. created() {
  393. this.getList(this.queryParams)
  394. },
  395. methods: {
  396. // 格式化表格内容
  397. formatterPlanType(row) {
  398. switch(row.planType){
  399. case 'ZJH':
  400. return '周计划'
  401. case 'YJH':
  402. return '月计划'
  403. case 'JJXQ':
  404. return '紧急计划'
  405. }
  406. },
  407. formatterStatus(row) {
  408. switch(row.status){
  409. case '0':
  410. return '未提交'
  411. case '1':
  412. return '审批中'
  413. case '2':
  414. return '已完成'
  415. case '3':
  416. return '已驳回'
  417. }
  418. },
  419. formatterBillType(row) {
  420. switch (row.billType) {
  421. case 'ZQBH':
  422. return '周期备货'
  423. case 'FXXQ':
  424. return '分销需求'
  425. case 'TSXQ':
  426. return '特殊采购需求'
  427. case 'BDXQ':
  428. return '补单需求'
  429. case 'JJXQ':
  430. return '紧急需求单'
  431. case 'XPXQ':
  432. return '新品需求'
  433. case 'HZBM':
  434. return '合作部门需求'
  435. case 'DZBH':
  436. return '大宗备货'
  437. case 'XZCG':
  438. return '行政类采购'
  439. }
  440. },
  441. formatterSource(row) {
  442. switch (row.source) {
  443. case '1':
  444. return '手工导入'
  445. case '2':
  446. return '按客户计算'
  447. case '3':
  448. return '按仓库计算'
  449. case '4':
  450. return '手工新增'
  451. }
  452. },
  453. searchList() {
  454. this.getList(this.queryParams)
  455. },
  456. resetList() {
  457. this.queryParams = {
  458. code: '',
  459. customer: '',
  460. isCustomerSpecified: '',
  461. demandPersonal: '',
  462. source: '',
  463. planType: '',
  464. billType: '',
  465. demandDept: '',
  466. demandDate: '',
  467. remark: '',
  468. materialCode: '',
  469. status: '',
  470. pageNum: 1,
  471. pageSize: 100
  472. }
  473. this.getList(this.queryParams)
  474. },
  475. getList(params){
  476. getDemandList(params).then(res => {
  477. if (res.code === 200) {
  478. this.tableList = res.rows
  479. this.total = res.total
  480. }
  481. }).then(() => {
  482. this.loading = false
  483. }).catch(err => {
  484. this.loading = false
  485. })
  486. },
  487. handleSelectionChange(selection) {
  488. console.log('选中', selection)
  489. this.ids = selection.map(item => item.id)
  490. console.log('选中数组', this.ids.join())
  491. },
  492. mbDownload() {
  493. this.$modal.loading("正在下载模板,请稍后...");
  494. downLoadDemand(this.download).then(res => {
  495. this.$modal.closeLoading();
  496. const blob = new Blob([res], {
  497. type: "application/vnd.ms-excel;charset=UTF-8",
  498. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  499. const downloadElement = document.createElement("a"); //创建a标签
  500. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  501. // var temp = res.headers["content-disposition"];
  502. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  503. // var name = fileName.split(";")[0]; //切割成文件名
  504. downloadElement.href = href; //下载地址
  505. downloadElement.download = '采购需求单模板'+ this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  506. document.body.appendChild(downloadElement);
  507. downloadElement.click(); // 点击下载
  508. document.body.removeChild(downloadElement); // 下载完成移除元素
  509. window.URL.revokeObjectURL(href); // 释放blob对象
  510. this.download.open = false
  511. }).catch(err => {
  512. this.$modal.closeLoading();
  513. })
  514. },
  515. // 关闭模板下载弹窗清空参数
  516. clearDownload() {
  517. // 模板下载参数
  518. this.download = {
  519. open: false,
  520. planType: 'ZJH',
  521. customer: '',
  522. warehouse: '',
  523. warehouseId: '',
  524. cargoSpace: '',
  525. category: ''
  526. }
  527. },
  528. handleCommand(command) {
  529. // alert(command)
  530. if(command == '模板下载') {
  531. this.download.open = true
  532. }
  533. if (command == '数据导入') {
  534. this.upload.title = "用户导入"
  535. this.upload.open = true
  536. }
  537. },
  538. // 文件上传中处理
  539. handleFileUploadProgress(event, file, fileList) {
  540. this.upload.isUploading = true;
  541. this.$modal.loading("正在导入数据,请稍后...");
  542. },
  543. // 文件上传成功处理
  544. handleFileSuccess(response, file, fileList) {
  545. this.$modal.closeLoading();
  546. this.upload.open = false;
  547. this.upload.isUploading = false;
  548. this.$refs.upload.clearFiles();
  549. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  550. this.getList(this.queryParams);
  551. },
  552. errorFile(err) {
  553. this.$modal.closeLoading();
  554. this.$modal.notifyError("文件已变动,请重新上传");
  555. },
  556. // 提交上传文件
  557. submitFileForm() {
  558. this.$refs.upload.submit();
  559. },
  560. handleExport(command) {
  561. if(command == '选中导出') {
  562. if (this.ids.length == 0) {
  563. this.$modal.notifyWarning("请选中至少一条数据");
  564. } else {
  565. this.$modal.loading("正在导出数据,请稍后...");
  566. let param = {all: false, ids: this.ids}
  567. exportDemand(param).then(res => {
  568. this.$modal.closeLoading();
  569. const blob = new Blob([res], {
  570. type: "application/vnd.ms-excel;charset=UTF-8",
  571. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  572. const downloadElement = document.createElement("a"); //创建a标签
  573. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  574. // var temp = res.headers["content-disposition"];
  575. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  576. // var name = fileName.split(";")[0]; //切割成文件名
  577. downloadElement.href = href; //下载地址
  578. downloadElement.download = '采购需求单选中导出' + this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  579. document.body.appendChild(downloadElement);
  580. downloadElement.click(); // 点击下载
  581. document.body.removeChild(downloadElement); // 下载完成移除元素
  582. window.URL.revokeObjectURL(href); // 释放blob对象
  583. }).catch(err => {
  584. this.$modal.closeLoading();
  585. })
  586. }
  587. } else {
  588. this.$modal.loading("正在导出数据,请稍后...");
  589. let param2 = {all: true}
  590. exportDemand(param2).then(res => {
  591. this.$modal.closeLoading();
  592. const blob = new Blob([res], {
  593. type: "application/vnd.ms-excel;charset=UTF-8",
  594. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  595. const downloadElement = document.createElement("a"); //创建a标签
  596. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  597. // var temp = res.headers["content-disposition"];
  598. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  599. // var name = fileName.split(";")[0]; //切割成文件名
  600. downloadElement.href = href; //下载地址
  601. downloadElement.download = '采购需求单全部导出' + this.parseTime(new Date().getTime()) + ".xlsx";
  602. document.body.appendChild(downloadElement);
  603. downloadElement.click(); // 点击下载
  604. document.body.removeChild(downloadElement); // 下载完成移除元素
  605. window.URL.revokeObjectURL(href); // 释放blob对象
  606. }).catch(err => {
  607. this.$modal.closeLoading();
  608. })
  609. }
  610. },
  611. addDivision() {
  612. this.isList = false
  613. this.page = 'add'
  614. this.disable = false
  615. },
  616. check(row) {
  617. this.isList = false
  618. this.page = 'check'
  619. this.rowDetail = row
  620. this.disable = true
  621. },
  622. doubleClick(row) {
  623. this.isList = false
  624. this.page = 'check'
  625. this.rowDetail = row
  626. this.disable = true
  627. },
  628. // 表格选中数据
  629. rowSelect(row) {
  630. this.$refs.tables.toggleRowSelection(row);
  631. },
  632. edit(row) {
  633. this.isList = false
  634. this.page = 'edit'
  635. this.rowDetail = row
  636. this.disable = false
  637. },
  638. commit(row) {
  639. console.log('row', row)
  640. this.$modal.loading("提交中...");
  641. submitDemand(row).then(res => {
  642. if (res.code === 200) {
  643. this.$modal.notifySuccess("提交成功");
  644. this.$modal.closeLoading();
  645. this.getList(this.queryParams)
  646. }
  647. }).catch(err => {
  648. this.$modal.closeLoading();
  649. })
  650. },
  651. // 流程收回
  652. reback(row) {
  653. let params = {billCode: row.code, fdId: row.flowId, fdTemplateId: '18804432233a7813df7921d436ab69b7' }
  654. rebacktWork(params).then(res => {
  655. })
  656. },
  657. // 行内删除
  658. deleteids(row) {
  659. console.log('row', row)
  660. this.$modal.confirm('确定删除选择数据?').then(() => {
  661. delDemand(row.id).then(res => {
  662. if (res.code === 200) {
  663. this.$modal.notifySuccess("删除成功");
  664. this.getList(this.queryParams)
  665. }
  666. })
  667. }).catch(() => {})
  668. },
  669. // 批量删除按钮
  670. delItems() {
  671. if(this.ids.length == 0) {
  672. this.$modal.notifyWarning("请选中至少一条数据");
  673. } else {
  674. let param = this.ids.join()
  675. this.$modal.confirm('确认删除选中数据?').then(() => {
  676. delDemand(param).then(res => {
  677. if (res.code === 200) {
  678. this.$modal.notifySuccess("删除成功");
  679. this.getList(this.queryParams)
  680. }
  681. })
  682. }).catch(() => {})
  683. }
  684. },
  685. handleSizeChange(val) {
  686. console.log(`每页 ${val} 条`);
  687. this.queryParams.pageSize = val
  688. this.getList(this.queryParams)
  689. },
  690. handleCurrentChange(val) {
  691. console.log(`当前页: ${val}`);
  692. this.queryParams.pageNum = val
  693. this.getList(this.queryParams)
  694. },
  695. drop() {
  696. this.expanded = !this.expanded
  697. },
  698. // 搜索区参照选择
  699. chooseOrg(type, isPage, title, stordocId) {
  700. this.referCondition.type = type
  701. this.referCondition.isPage = isPage
  702. this.referCondition.title = title
  703. this.referCondition.stordocId = stordocId
  704. this.$refs.refer.init(this.referCondition)
  705. },
  706. selectionsToInput(selection) {
  707. // 搜索区选择客户
  708. if (this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '需求客户') {
  709. this.customerOptions = selection
  710. this.queryParams.customer = selection[0].id
  711. }
  712. // 模板内选择客户
  713. if (this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '选择客户') {
  714. this.mBcustomer = selection
  715. this.download.customer = selection[0].code
  716. }
  717. // 模板内选择仓库
  718. if (this.referCondition.type == 'WAREHOUSE_PARAM' && this.referCondition.title == '选择仓库') {
  719. this.mBwarehouse = selection
  720. this.download.warehouse = selection[0].code
  721. this.download.warehouseId = selection[0].id
  722. }
  723. // 模板内选择货位
  724. if (this.referCondition.type == 'ALLOCATION_PARAM' && this.referCondition.title == '选择货位') {
  725. this.mBcargoSpace = selection
  726. this.download.cargoSpace = selection[0].code
  727. }
  728. if (this.referCondition.type == 'CONTACTS_PARAM') {
  729. this.personOptions = selection
  730. this.queryParams.demandPersonal = selection[0].code
  731. }
  732. if (this.referCondition.type == 'DEPT_PARAM') {
  733. this.deptOptions = selection
  734. this.queryParams.demandDept = selection[0].id
  735. }
  736. },
  737. mbHuowei(type, isPage, title, stordocId) {
  738. this.referCondition.type = type
  739. this.referCondition.isPage = isPage
  740. this.referCondition.title = title
  741. if(stordocId) {
  742. this.referCondition.stordocId = stordocId
  743. this.$refs.refer.init(this.referCondition)
  744. } else {
  745. this.$modal.notifyWarning("请先选择仓库")
  746. }
  747. },
  748. cleanMb() {
  749. this.download.warehouse = ''
  750. this.download.warehouseId = ''
  751. },
  752. // 搜索区树形选择
  753. chooseTreeRefer(type, isPage, title) {
  754. this.referCondition.type = type
  755. this.referCondition.isPage = isPage
  756. this.referCondition.title = title
  757. this.$refs.tree.init(this.referCondition)
  758. },
  759. selectionsToInput2(selection) {
  760. this.classOptions.push(selection)
  761. this.download.category = selection.code
  762. },
  763. }
  764. }
  765. </script>
  766. <style lang="scss" scoped>
  767. #PurchaseDemandList {
  768. padding: 12px;
  769. box-sizing: border-box;
  770. overflow-y: scroll;
  771. }
  772. .btn_grooup {
  773. margin-bottom: 10px;
  774. display: flex;
  775. justify-content: flex-end;
  776. }
  777. .lines {
  778. margin-top: 0;
  779. }
  780. .el-pagination {
  781. margin-top: 10px;
  782. text-align: right;
  783. }
  784. ::v-deep .el-table__row > td {
  785. border-right: none;
  786. }
  787. ::v-deep .el-card .el-form-item {
  788. margin-bottom: 10px;
  789. }
  790. </style>
  791. <style>
  792. .exporttable {
  793. border: solid 1px #c0c0c0;
  794. }
  795. .el-table .el-table__header-wrapper th {
  796. font-size: 14px;
  797. }
  798. </style>