index.vue 21 KB

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