index.vue 34 KB

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