index.vue 32 KB

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