index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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' || scope.row.status == '9'" @click="edit(scope.row)">编辑</el-button>
  203. <el-button type="text" size="mini" v-if="scope.row.status == '0' || scope.row.status == '3' || scope.row.status == '9'" @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' || scope.row.status == '9'" @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="50"
  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, confirmSubmit } 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: 50
  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. case '9':
  418. return '已回退'
  419. }
  420. },
  421. formatterBillType(row) {
  422. switch (row.billType) {
  423. case 'ZQBH':
  424. return '周期备货'
  425. case 'FXXQ':
  426. return '分销需求'
  427. case 'TSXQ':
  428. return '特殊采购需求'
  429. case 'BDXQ':
  430. return '补单需求'
  431. case 'JJXQ':
  432. return '紧急需求单'
  433. case 'XPXQ':
  434. return '新品需求'
  435. case 'HZBM':
  436. return '合作部门需求'
  437. case 'DZBH':
  438. return '大宗备货'
  439. case 'XZCG':
  440. return '行政类采购'
  441. }
  442. },
  443. formatterSource(row) {
  444. switch (row.source) {
  445. case '1':
  446. return '手工导入'
  447. case '2':
  448. return '按客户计算'
  449. case '3':
  450. return '按仓库计算'
  451. case '4':
  452. return '手工新增'
  453. }
  454. },
  455. searchList() {
  456. this.getList(this.queryParams)
  457. },
  458. resetList() {
  459. this.queryParams = {
  460. code: '',
  461. customer: '',
  462. isCustomerSpecified: '',
  463. demandPersonal: '',
  464. source: '',
  465. planType: '',
  466. billType: '',
  467. demandDept: '',
  468. demandDate: '',
  469. remark: '',
  470. materialCode: '',
  471. status: '',
  472. pageNum: 1,
  473. pageSize: 50
  474. }
  475. this.getList(this.queryParams)
  476. },
  477. getList(params){
  478. getDemandList(params).then(res => {
  479. if (res.code === 200) {
  480. this.tableList = res.rows
  481. this.total = res.total
  482. }
  483. }).then(() => {
  484. this.loading = false
  485. }).catch(err => {
  486. this.loading = false
  487. })
  488. },
  489. handleSelectionChange(selection) {
  490. console.log('选中', selection)
  491. this.ids = selection.map(item => item.id)
  492. console.log('选中数组', this.ids.join())
  493. },
  494. mbDownload() {
  495. this.$modal.loading("正在下载模板,请稍后...");
  496. downLoadDemand(this.download).then(res => {
  497. this.$modal.closeLoading();
  498. const blob = new Blob([res], {
  499. type: "application/vnd.ms-excel;charset=UTF-8",
  500. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  501. const downloadElement = document.createElement("a"); //创建a标签
  502. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  503. // var temp = res.headers["content-disposition"];
  504. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  505. // var name = fileName.split(";")[0]; //切割成文件名
  506. downloadElement.href = href; //下载地址
  507. downloadElement.download = '采购需求单模板'+ this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  508. document.body.appendChild(downloadElement);
  509. downloadElement.click(); // 点击下载
  510. document.body.removeChild(downloadElement); // 下载完成移除元素
  511. window.URL.revokeObjectURL(href); // 释放blob对象
  512. this.download.open = false
  513. }).catch(err => {
  514. this.$modal.closeLoading();
  515. })
  516. },
  517. // 关闭模板下载弹窗清空参数
  518. clearDownload() {
  519. // 模板下载参数
  520. this.download = {
  521. open: false,
  522. planType: 'ZJH',
  523. customer: '',
  524. warehouse: '',
  525. warehouseId: '',
  526. cargoSpace: '',
  527. category: ''
  528. }
  529. },
  530. handleCommand(command) {
  531. // alert(command)
  532. if(command == '模板下载') {
  533. this.download.open = true
  534. }
  535. if (command == '数据导入') {
  536. this.upload.title = "用户导入"
  537. this.upload.open = true
  538. }
  539. },
  540. // 文件上传中处理
  541. handleFileUploadProgress(event, file, fileList) {
  542. this.upload.isUploading = true;
  543. this.$modal.loading("正在导入数据,请稍后...");
  544. },
  545. // 文件上传成功处理
  546. handleFileSuccess(response, file, fileList) {
  547. this.$modal.closeLoading();
  548. this.upload.open = false;
  549. this.upload.isUploading = false;
  550. this.$refs.upload.clearFiles();
  551. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  552. this.getList(this.queryParams);
  553. },
  554. errorFile(err) {
  555. this.$modal.closeLoading();
  556. this.$modal.notifyError("文件已变动,请重新上传");
  557. },
  558. // 提交上传文件
  559. submitFileForm() {
  560. this.$refs.upload.submit();
  561. },
  562. handleExport(command) {
  563. if(command == '选中导出') {
  564. if (this.ids.length == 0) {
  565. this.$modal.notifyWarning("请选中至少一条数据");
  566. } else {
  567. this.$modal.loading("正在导出数据,请稍后...");
  568. let param = {all: false, ids: this.ids}
  569. exportDemand(param).then(res => {
  570. this.$modal.closeLoading();
  571. const blob = new Blob([res], {
  572. type: "application/vnd.ms-excel;charset=UTF-8",
  573. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  574. const downloadElement = document.createElement("a"); //创建a标签
  575. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  576. // var temp = res.headers["content-disposition"];
  577. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  578. // var name = fileName.split(";")[0]; //切割成文件名
  579. downloadElement.href = href; //下载地址
  580. downloadElement.download = '采购需求单选中导出' + this.parseTime(new Date().getTime()) + ".xlsx"; // 下载后文件名
  581. document.body.appendChild(downloadElement);
  582. downloadElement.click(); // 点击下载
  583. document.body.removeChild(downloadElement); // 下载完成移除元素
  584. window.URL.revokeObjectURL(href); // 释放blob对象
  585. }).catch(err => {
  586. this.$modal.closeLoading();
  587. })
  588. }
  589. } else {
  590. this.$modal.loading("正在导出数据,请稍后...");
  591. let param2 = {all: true}
  592. exportDemand(param2).then(res => {
  593. this.$modal.closeLoading();
  594. const blob = new Blob([res], {
  595. type: "application/vnd.ms-excel;charset=UTF-8",
  596. });// 创建一个类文件对象:Blob对象表示一个不可变的、原始数据的类文件对象
  597. const downloadElement = document.createElement("a"); //创建a标签
  598. const href = window.URL.createObjectURL(blob); // 创建下载的链接
  599. // var temp = res.headers["content-disposition"];
  600. // var fileName = decodeURIComponent(temp.split("filename=")[1]); // 中文需要转码 (前端乱码)
  601. // var name = fileName.split(";")[0]; //切割成文件名
  602. downloadElement.href = href; //下载地址
  603. downloadElement.download = '采购需求单全部导出' + this.parseTime(new Date().getTime()) + ".xlsx";
  604. document.body.appendChild(downloadElement);
  605. downloadElement.click(); // 点击下载
  606. document.body.removeChild(downloadElement); // 下载完成移除元素
  607. window.URL.revokeObjectURL(href); // 释放blob对象
  608. }).catch(err => {
  609. this.$modal.closeLoading();
  610. })
  611. }
  612. },
  613. addDivision() {
  614. this.isList = false
  615. this.page = 'add'
  616. this.disable = false
  617. },
  618. check(row) {
  619. this.isList = false
  620. this.page = 'check'
  621. this.rowDetail = row
  622. this.disable = true
  623. },
  624. doubleClick(row) {
  625. this.isList = false
  626. this.page = 'check'
  627. this.rowDetail = row
  628. this.disable = true
  629. },
  630. // 表格选中数据
  631. rowSelect(row) {
  632. this.$refs.tables.toggleRowSelection(row);
  633. },
  634. edit(row) {
  635. this.isList = false
  636. this.page = 'edit'
  637. this.rowDetail = row
  638. this.disable = false
  639. },
  640. commit(row) {
  641. console.log('row', row)
  642. this.$modal.loading("提交中...");
  643. submitDemand(row).then(res => {
  644. if (res.code === 200) {
  645. this.$modal.notifySuccess("提交成功");
  646. this.$modal.closeLoading();
  647. this.getList(this.queryParams)
  648. }
  649. if (res.code === 233) {
  650. this.$modal.confirm(res.msg).then(function() {
  651. // 确认
  652. }).then(() => {
  653. confirmSubmit(row).then(res => {
  654. if (res.code === 200) {
  655. this.$modal.notifySuccess("提交成功");
  656. this.$modal.closeLoading();
  657. this.getList(this.queryParams)
  658. }
  659. }).catch(err => {
  660. this.$modal.closeLoading();
  661. })
  662. // 取消
  663. }).catch(() => {
  664. this.$modal.closeLoading();
  665. })
  666. this.$modal.closeLoading();
  667. }
  668. }).catch(err => {
  669. this.$modal.closeLoading();
  670. })
  671. },
  672. // 流程收回
  673. reback(row) {
  674. this.$modal.loading("收回中...");
  675. let params = {billCode: row.code, fdId: row.flowId, fdTemplateId: '18804432233a7813df7921d436ab69b7',billMaker: row.createBy }
  676. rebacktWork(params).then(res => {
  677. if (res.code === 200) {
  678. this.$modal.notifySuccess("收回成功");
  679. this.$modal.closeLoading();
  680. this.getList(this.queryParams)
  681. }
  682. }).catch(err => {
  683. this.$modal.closeLoading();
  684. })
  685. },
  686. // 行内删除
  687. deleteids(row) {
  688. console.log('row', row)
  689. this.$modal.confirm('确定删除选择数据?').then(() => {
  690. delDemand(row.id).then(res => {
  691. if (res.code === 200) {
  692. this.$modal.notifySuccess("删除成功");
  693. this.getList(this.queryParams)
  694. }
  695. })
  696. }).catch(() => {})
  697. },
  698. // 批量删除按钮
  699. delItems() {
  700. if(this.ids.length == 0) {
  701. this.$modal.notifyWarning("请选中至少一条数据");
  702. } else {
  703. let param = this.ids.join()
  704. this.$modal.confirm('确认删除选中数据?').then(() => {
  705. delDemand(param).then(res => {
  706. if (res.code === 200) {
  707. this.$modal.notifySuccess("删除成功");
  708. this.getList(this.queryParams)
  709. }
  710. })
  711. }).catch(() => {})
  712. }
  713. },
  714. handleSizeChange(val) {
  715. console.log(`每页 ${val} 条`);
  716. this.queryParams.pageSize = val
  717. this.getList(this.queryParams)
  718. },
  719. handleCurrentChange(val) {
  720. console.log(`当前页: ${val}`);
  721. this.queryParams.pageNum = val
  722. this.getList(this.queryParams)
  723. },
  724. drop() {
  725. this.expanded = !this.expanded
  726. },
  727. // 搜索区参照选择
  728. chooseOrg(type, isPage, title, stordocId) {
  729. this.referCondition.type = type
  730. this.referCondition.isPage = isPage
  731. this.referCondition.title = title
  732. this.referCondition.stordocId = stordocId
  733. this.$refs.refer.init(this.referCondition)
  734. },
  735. selectionsToInput(selection) {
  736. // 搜索区选择客户
  737. if (this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '需求客户') {
  738. this.customerOptions = selection
  739. this.queryParams.customer = selection[0].id
  740. }
  741. // 模板内选择客户
  742. if (this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '选择客户') {
  743. this.mBcustomer = selection
  744. this.download.customer = selection[0].code
  745. }
  746. // 模板内选择仓库
  747. if (this.referCondition.type == 'WAREHOUSE_PARAM' && this.referCondition.title == '选择仓库') {
  748. this.mBwarehouse = selection
  749. this.download.warehouse = selection[0].code
  750. this.download.warehouseId = selection[0].id
  751. }
  752. // 模板内选择货位
  753. if (this.referCondition.type == 'ALLOCATION_PARAM' && this.referCondition.title == '选择货位') {
  754. this.mBcargoSpace = selection
  755. this.download.cargoSpace = selection[0].code
  756. }
  757. if (this.referCondition.type == 'CONTACTS_PARAM') {
  758. this.personOptions = selection
  759. this.queryParams.demandPersonal = selection[0].code
  760. }
  761. if (this.referCondition.type == 'DEPT_PARAM') {
  762. this.deptOptions = selection
  763. this.queryParams.demandDept = selection[0].id
  764. }
  765. },
  766. mbHuowei(type, isPage, title, stordocId) {
  767. this.referCondition.type = type
  768. this.referCondition.isPage = isPage
  769. this.referCondition.title = title
  770. if(stordocId) {
  771. this.referCondition.stordocId = stordocId
  772. this.$refs.refer.init(this.referCondition)
  773. } else {
  774. this.$modal.notifyWarning("请先选择仓库")
  775. }
  776. },
  777. cleanMb() {
  778. this.download.warehouse = ''
  779. this.download.warehouseId = ''
  780. },
  781. // 搜索区树形选择
  782. chooseTreeRefer(type, isPage, title) {
  783. this.referCondition.type = type
  784. this.referCondition.isPage = isPage
  785. this.referCondition.title = title
  786. this.$refs.tree.init(this.referCondition)
  787. },
  788. selectionsToInput2(selection) {
  789. this.classOptions.push(selection)
  790. this.download.category = selection.code
  791. },
  792. }
  793. }
  794. </script>
  795. <style lang="scss" scoped>
  796. #PurchaseDemandList {
  797. padding: 12px;
  798. box-sizing: border-box;
  799. overflow-y: scroll;
  800. }
  801. .btn_grooup {
  802. margin-bottom: 10px;
  803. display: flex;
  804. justify-content: flex-end;
  805. }
  806. .lines {
  807. margin-top: 0;
  808. }
  809. .el-pagination {
  810. margin-top: 10px;
  811. text-align: right;
  812. }
  813. ::v-deep .el-table__row > td {
  814. border-right: none;
  815. }
  816. ::v-deep .el-card .el-form-item {
  817. margin-bottom: 10px;
  818. }
  819. </style>
  820. <style>
  821. .exporttable {
  822. border: solid 1px #c0c0c0;
  823. }
  824. .el-table .el-table__header-wrapper th {
  825. font-size: 14px;
  826. }
  827. </style>