Dispatching.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <div>
  3. <Toptitle title="派工">
  4. <Button @click="goBack" type="primary" ghost style="margin-right:10px;"
  5. >返回</Button
  6. >
  7. <Button
  8. @click="handleGoPage"
  9. type="primary"
  10. ghost
  11. style="margin-right:10px;"
  12. >派工单查询</Button
  13. >
  14. <Button
  15. @click="handleDispatchConfirm"
  16. type="primary"
  17. style="margin-right:10px;"
  18. >确认派工</Button
  19. >
  20. </Toptitle>
  21. <div class="main">
  22. <Form style='display:flex;margin:15px 0' :label-width='100'>
  23. <FormItem label='订单编号:' >
  24. <Select style="width:200px" v-model="searchData.order_no">
  25. <Option value="1">1</Option>
  26. </Select>
  27. </FormItem>
  28. <FormItem label='图号:'>
  29. <Select style="width:200px" v-model="searchData.url_number">
  30. <Option value="2">1</Option>
  31. </Select>
  32. </FormItem>
  33. <FormItem>
  34. <Button type="primary">搜索</Button>
  35. </FormItem>
  36. </Form>
  37. <div class="header">
  38. <Tabs v-model="currencyTag" @on-click="handleProcedureChange">
  39. <TabPane
  40. v-for="item in basicsProcedureList"
  41. :key="item.id"
  42. :label="item.title"
  43. :name="item.id + ''"
  44. />
  45. <div slot="extra" style="width:250px;line-height:40px;font-size:12px">
  46. <label style="width:130px">批量设置班组:</label>
  47. <Select v-model="group" size='small' style="z-index:99;position: fixed;width:150px;margin-top: 6px;margin-left:10px" @on-change='change_NK'> <Option :value="_item.id" :label="_item.nickname" v-for="_item in groupList" :key="_item.id">
  48. </Option> </Select>
  49. </div>
  50. </Tabs>
  51. </div>
  52. <div class="content">
  53. <Table
  54. :columns="tableColumns"
  55. border
  56. max-height="700"
  57. @on-selection-change="handleSelectionChange"
  58. @on-select='changeSelect'
  59. :data="tableData"
  60. ref="y_table"
  61. >
  62. <template slot="slotGroup" slot-scope="{ row, index }">
  63. <Select
  64. v-model="row.employee_id"
  65. size="small"
  66. @on-change="
  67. (e) =>
  68. handleGroupSelect(
  69. e,
  70. tableData[index],
  71. index,
  72. tableData[index].employee_id
  73. )
  74. "
  75. clearable
  76. style="width: 150px"
  77. >
  78. <Option
  79. v-for="sitem in groupList"
  80. :key="sitem.id"
  81. :label="sitem.nickname"
  82. :value="sitem.id"
  83. >
  84. </Option>
  85. </Select>
  86. </template>
  87. <template slot="slotSet" slot-scope="{ row, index }">
  88. <a style="margin:0 5px" @click="handleSet(row, index)">详情</a>
  89. <!-- <a style="margin:0 5px" @click="handleDispatchConfirm(row, index)"
  90. >派工</a
  91. > -->
  92. </template>
  93. </Table>
  94. </div>
  95. </div>
  96. <div class="pageSlotStyle">
  97. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  98. @on-page-size-change='changeSize'
  99. @on-change='changePage'
  100. :current='page_index'
  101. show-total
  102. :total="total"
  103. show-sizer
  104. :page-size='page_size' />
  105. </div>
  106. <Modal v-model="showModal" title="确认派工">
  107. <Form :label-width="85" ref="forms" :model="dispatchInfo">
  108. <FormItem label="选择时间">
  109. <DatePicker
  110. :options="options"
  111. style="width:100%;"
  112. v-model="dispatchTime"
  113. clearable
  114. type="daterange"
  115. split-panels
  116. placeholder="请选择日期"
  117. ></DatePicker>
  118. </FormItem>
  119. <FormItem label="点工单形式">
  120. <RadioGroup v-model="dispatchInfo.work_type">
  121. <Radio :label="1">是</Radio>
  122. <Radio :label="0">否</Radio>
  123. </RadioGroup>
  124. </FormItem>
  125. <FormItem label="日薪" v-if="dispatchInfo.work_type == 1">
  126. <Input v-model="dispatchInfo.user_salary">
  127. <span slot="append">元</span>
  128. </Input>
  129. </FormItem>
  130. </Form>
  131. <div slot="footer">
  132. <Button @click="showModal = false">取消</Button>
  133. <Button type="primary" @click="handleDispatch(subArr, subUrl)"
  134. >确认</Button
  135. >
  136. </div>
  137. </Modal>
  138. <Modal v-model="showModalAll" title="全部派工">
  139. <Table
  140. :columns="modalTableColumns"
  141. border
  142. max-height="700"
  143. :data="modalTableData"
  144. >
  145. <template slot="slotGroup" slot-scope="{ row, index }">
  146. <Select
  147. v-model="row.employee_id"
  148. size="small"
  149. @on-change="
  150. (e) =>
  151. handleGroupSelect(
  152. e,
  153. modalTableData[index],
  154. index,
  155. modalTableData[index].employee_id
  156. )
  157. "
  158. clearable
  159. style="width: 120px"
  160. >
  161. <Option
  162. v-for="sitem in groupList"
  163. :key="sitem.id"
  164. :label="sitem.nickname"
  165. :value="sitem.id"
  166. >
  167. </Option>
  168. </Select>
  169. </template>
  170. </Table>
  171. <div slot="footer">
  172. <Button @click="showModalAll = false">取消</Button>
  173. <Button type="primary" @click="handleDispatchAllConfirm">确认</Button>
  174. </div>
  175. </Modal>
  176. </div>
  177. </template>
  178. <script>
  179. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  180. // 例如:import 《组件名称》 from '《组件路径》';
  181. export default {
  182. name: "",
  183. components: {},
  184. props: {},
  185. // import引入的组件需要注入到对象中才能使用
  186. data() {
  187. // 这里存放数据
  188. return {
  189. tableColumns: [
  190. { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  191. { title: "工序", align: "center", key: "title", minWidth: 150 },
  192. { title: "部件总数", align: "center", key: "num", minWidth: 150 },
  193. {
  194. title: "班组",
  195. align: "center",
  196. key: "",
  197. minWidth: 150,
  198. slot: "slotGroup",
  199. },
  200. {
  201. title: "操作",
  202. align: "center",
  203. key: "",
  204. minWidth: 100,
  205. slot: "slotSet",
  206. },
  207. ],
  208. modalTableColumns: [
  209. { title: "工序", align: "center", key: "title", minWidth: 150 },
  210. { title: "部件总数", align: "center", key: "num", minWidth: 150 },
  211. {
  212. title: "班组",
  213. align: "center",
  214. key: "",
  215. minWidth: 150,
  216. slot: "slotGroup",
  217. },
  218. ],
  219. modalTableData: [{}],
  220. tableData: [{}],
  221. page_index: 1,
  222. page_size: 10,
  223. total: 0,
  224. group:'',
  225. basicsProcedureList: [],
  226. groupList: [],
  227. currencyTag: "1",
  228. dispatchTime: [],
  229. wood_select:[],
  230. wood_group:'',
  231. paint_select:[],
  232. paint_group:'',
  233. packing_select:[],
  234. packing_group:'',
  235. transit_select:[],
  236. transit_group:'',
  237. install_select:[],
  238. install_group:'',
  239. selected: [],
  240. searchData:{
  241. order_no:'',
  242. url_number:''
  243. },
  244. showModal: false,
  245. showModalAll: false,
  246. options: {
  247. disabledDate(date) {
  248. return date && date.valueOf() < Date.now() - 86400000;
  249. },
  250. },
  251. dispatchInfo: {},
  252. subArr: [],
  253. subUrl: "",
  254. };
  255. },
  256. // 生命周期 - 创建完成(可以访问当前this实例)
  257. created() {
  258. // 获取工序分类列表
  259. this.axios({ method: "get", url: "/api/basics_procedure_index" })
  260. .then((res) => {
  261. (this.basicsProcedureList = res.data.data),
  262. (this.currencyTag =
  263. localStorage.getItem("dispatchTag") || this.currencyTag + "");
  264. })
  265. .catch((err) => {});
  266. //获取班组列表
  267. this.axios("/api/employee_list").then(
  268. (res) => (this.groupList = res.data)
  269. );
  270. },
  271. // 生命周期 - 挂载完成(可以访问DOM元素)
  272. mounted() {
  273. this.initData();
  274. },
  275. methods: {
  276. changeSelect(row){
  277. },
  278. change_NK(row){
  279. if(row == null){
  280. return
  281. }else{
  282. if(this.currencyTag == 1){
  283. if(this.wood_select.length == 0){
  284. this.$Message.warning('请先选择工序!')
  285. }else{
  286. this.tableData.forEach(item=>{
  287. this.wood_select.forEach(_item=>{
  288. if(_item.id == item.id){
  289. item.employee_id = row;
  290. item._checked = true;
  291. _item.employee_id = row;
  292. }
  293. })
  294. })
  295. }
  296. }
  297. if(this.currencyTag == 2){
  298. if(this.paint_select.length == 0){
  299. this.$Message.warning('请先选择工序!')
  300. }else{
  301. this.tableData.forEach(item=>{
  302. this.paint_select.forEach(_item=>{
  303. if(_item.id == item.id){
  304. item.employee_id = row;
  305. item._checked = true;
  306. _item.employee_id = row;
  307. }
  308. })
  309. })
  310. }
  311. }
  312. if(this.currencyTag == 3){
  313. if(this.packing_select.length == 0){
  314. this.$Message.warning('请先选择工序!')
  315. }else{
  316. this.tableData.forEach(item=>{
  317. this.packing_select.forEach(_item=>{
  318. if(_item.id == item.id){
  319. item.employee_id = row;
  320. item._checked = true;
  321. _item.employee_id = row;
  322. }
  323. })
  324. })
  325. }
  326. }
  327. if(this.currencyTag == 4){
  328. if(this.transit_select.length == 0){
  329. this.$Message.warning('请先选择工序!')
  330. }else{
  331. this.tableData.forEach(item=>{
  332. this.transit_select.forEach(_item=>{
  333. if(_item.id == item.id){
  334. item.employee_id = row;
  335. item._checked = true;
  336. _item.employee_id = row;
  337. }
  338. })
  339. })
  340. }
  341. }
  342. if(this.currencyTag == 5){
  343. if(this.install_select.length == 0){
  344. this.$Message.warning('请先选择工序!')
  345. }else{
  346. this.tableData.forEach(item=>{
  347. this.install_select.forEach(_item=>{
  348. if(_item.id == item.id){
  349. item.employee_id = row;
  350. item._checked = true;
  351. _item.employee_id = row;
  352. }
  353. })
  354. })
  355. }
  356. }
  357. }
  358. },
  359. initData() {
  360. this.axios({
  361. method: "get",
  362. url: "/api/order_produce_list",
  363. params: {
  364. basics_procedure_id:
  365. localStorage.getItem("dispatchTag") || this.currencyTag,
  366. page_index:this.page_index,
  367. page_size:this.page_size,
  368. },
  369. })
  370. .then((res) => {
  371. this.group = '';
  372. this.total = res.data.total;
  373. this.tableData = res.data.data;
  374. this.tableData.forEach((element) => {
  375. element.produce_id = element.id;
  376. element.employee_id ? "" : (element.employee_id = "");
  377. if(this.currencyTag == 1 ){
  378. this.wood_select.forEach(_item=>{
  379. if(_item.id == element.id){
  380. element._checked = true;
  381. element.employee_id = _item.employee_id;
  382. }
  383. })
  384. }
  385. if(this.currencyTag == 2 ){
  386. this.paint_select.forEach(_item=>{
  387. if(_item.id == element.id){
  388. element._checked = true;
  389. element.employee_id = _item.employee_id;
  390. }
  391. })
  392. }
  393. if(this.currencyTag == 3 ){
  394. this.packing_select.forEach(_item=>{
  395. if(_item.id == element.id){
  396. element._checked = true;
  397. element.employee_id = _item.employee_id;
  398. }
  399. })
  400. }
  401. if(this.currencyTag == 4 ){
  402. this.transit_select.forEach(_item=>{
  403. if(_item.id == element.id){
  404. element._checked = true;
  405. element.employee_id = _item.employee_id;
  406. }
  407. })
  408. }
  409. if(this.currencyTag == 5 ){
  410. this.install_select.forEach(_item=>{
  411. if(_item.id == element.id){
  412. element._checked = true;
  413. element.employee_id = _item.employee_id;
  414. }
  415. })
  416. }
  417. });
  418. this.$forceUpdate();
  419. })
  420. .catch((err) => {});
  421. },
  422. goBack() {
  423. this.$router.go(-1);
  424. },
  425. handleGoPage() {
  426. this.$router.push({ path: "/cms/Dispatching/DispatchedList" });
  427. },
  428. handleSet(row, index) {
  429. this.$router.push({
  430. path: "/cms/Dispatching/DispatchingDetail",
  431. query: {
  432. produce_id: row.id,
  433. },
  434. });
  435. },
  436. // handleDispatchConfirm(row, index) {
  437. // if (row.employee_id) {
  438. // this.selected = [row];
  439. // this.showModal = true;
  440. // this.subArr = JSON.parse(JSON.stringify(this.selected));
  441. // this.subUrl = "/api/order_produce_pull_all";
  442. // } else {
  443. // this.$Message.warning("请选择班组");
  444. // }
  445. // },
  446. handleDispatchConfirm() {
  447. if (this.wood_select.length!=0||this.paint_select.length!=0||this.packing_select.length!=0||this.transit_select.length!=0||this.install_select.length!=0) {
  448. this.showModal = true;
  449. this.subArr =[...this.wood_select,...this.paint_select,...this.packing_select,...this.transit_select,...this.install_select]
  450. this.subUrl = "/api/order_produce_pull_all";
  451. } else {
  452. this.$Message.warning("请选择班组");
  453. }
  454. },
  455. handleDispatch(target, url) {
  456. if (!this.dispatchTime[0]) {
  457. this.$Message.warning("请选择时间");
  458. } else {
  459. this.dispatchInfo.start_time = new Date(this.dispatchTime[0])
  460. .toLocaleDateString()
  461. .replace(/\//g, "-");
  462. this.dispatchInfo.end_time = new Date(this.dispatchTime[1])
  463. .toLocaleDateString()
  464. .replace(/\//g, "-");
  465. target.forEach((element) => {
  466. element.start_time = this.dispatchInfo.start_time;
  467. element.end_time = this.dispatchInfo.end_time;
  468. element.work_type = this.dispatchInfo.work_type;
  469. element.user_salary = this.dispatchInfo.user_salary || "";
  470. });
  471. console.log(target);
  472. this.axios({
  473. method: "post",
  474. url,
  475. data: {
  476. ...target,
  477. },
  478. })
  479. .then((res) => {
  480. if (res.code == 200) {
  481. this.showModal = false;
  482. this.$Message.success(res.msg || "操作成功");
  483. this.initData();
  484. this.dispatchInfo = {};
  485. this.dispatchTime = [];
  486. }
  487. })
  488. .catch((err) => {});
  489. }
  490. },
  491. handleDispatchAllConfirm() {
  492. let flag = true;
  493. this.modalTableData.forEach((element) => {
  494. if (!element.employee_id || element.employee_id <= 0) {
  495. flag = false;
  496. }
  497. });
  498. if (flag) {
  499. (this.showModalAll = false), (this.showModal = true);
  500. this.subArr = JSON.parse(JSON.stringify(this.modalTableData));
  501. this.subUrl = "/api/all_order_produce_pull";
  502. } else {
  503. this.$Message.warning("请选择班组");
  504. }
  505. },
  506. handleDispatchAllOpen() {
  507. this.axios
  508. .get("/api/get_all_order_produce", {
  509. params: {
  510. basics_procedure_id:
  511. localStorage.getItem("dispatchTag") | this.currencyTag,
  512. },
  513. })
  514. .then((res) => {
  515. if (res.code == 200) {
  516. this.modalTableData = res.data;
  517. this.modalTableData.forEach((element) => {
  518. element.produce_id = element.id;
  519. });
  520. this.showModalAll = true;
  521. }
  522. });
  523. },
  524. changePage(e) {
  525. this.page_index = e;
  526. this.initData();
  527. },
  528. changeSize(e) {
  529. this.page_size = e;
  530. this.initData();
  531. },
  532. handleProcedureChange(val) {
  533. this.selected = [];
  534. this.currencyTag = val;
  535. localStorage.setItem("dispatchTag", val);
  536. this.initData();
  537. this.page_index = 1;
  538. this.page_size = 10;
  539. },
  540. handleSelectionChange(selection) {
  541. try{
  542. if(this.currencyTag == 1){
  543. this.wood_select = selection;
  544. this.wood_select.forEach((item,index)=>{
  545. if(this.wood_select[index].id!=this.tableData[index].id){
  546. this.$Message.error('请按流程选择工序!');
  547. throw new Error();
  548. }
  549. })
  550. }
  551. if(this.currencyTag == 2){
  552. this.paint_select =selection;
  553. this.paint_select.forEach((item,index)=>{
  554. if(this.paint_select[index].id!=this.tableData[index].id){
  555. this.$Message.error('请按流程选择工序!');
  556. throw new Error();
  557. }
  558. })
  559. }
  560. if(this.currencyTag == 3){
  561. this.packing_select =selection;
  562. this.packing_select.forEach((item,index)=>{
  563. if(this.packing_select[index].id!=this.tableData[index].id){
  564. this.$Message.error('请按流程选择工序!');
  565. throw new Error();
  566. }
  567. })
  568. }
  569. if(this.currencyTag == 4){
  570. this.transit_select = selection;
  571. this.transit_select.forEach((item,index)=>{
  572. if(this.transit_select[index].id!=this.tableData[index].id){
  573. this.$Message.error('请按流程选择工序!');
  574. throw new Error();
  575. }
  576. })
  577. }
  578. if(this.currencyTag == 5){
  579. this.install_select = selection;
  580. this.install_select.forEach((item,index)=>{
  581. if(this.install_select[index].id!=this.tableData[index].id){
  582. this.$Message.error('请按流程选择工序!');
  583. throw new Error();
  584. }
  585. })
  586. }
  587. }catch(e){
  588. }
  589. },
  590. handleGroupSelect(e, row, index, value) {
  591. // if (this.selected.length > 0) {
  592. // this.selected.forEach(element => {
  593. // if (element.id == row.id) {
  594. // element.employee_id = value
  595. // }
  596. // });
  597. // }
  598. row.employee_id = e;
  599. if(this.currencyTag == 1){
  600. this.tableData.forEach(item=>{
  601. this.wood_select.forEach(_item=>{
  602. if(item.id == _item.id){
  603. item._checked = true;
  604. _item.employee_id = item.employee_id;
  605. }
  606. })
  607. })
  608. }
  609. if(this.currencyTag == 2){
  610. this.tableData.forEach(item=>{
  611. this.paint_select.forEach(_item=>{
  612. if(item.id == _item.id){
  613. item._checked = true;
  614. _item.employee_id = item.employee_id;
  615. }
  616. })
  617. })
  618. }
  619. if(this.currencyTag == 3){
  620. this.tableData.forEach(item=>{
  621. this.packing_select.forEach(_item=>{
  622. if(item.id == _item.id){
  623. item._checked = true;
  624. _item.employee_id = item.employee_id;
  625. }
  626. })
  627. })
  628. }
  629. if(this.currencyTag == 4){
  630. this.tableData.forEach(item=>{
  631. this.transit_select.forEach(_item=>{
  632. if(item.id == _item.id){
  633. item._checked = true;
  634. _item.employee_id = item.employee_id;
  635. }
  636. })
  637. })
  638. }
  639. if(this.currencyTag == 5){
  640. this.tableData.forEach(item=>{
  641. this.install_select.forEach(_item=>{
  642. if(item.id == _item.id){
  643. item._checked = true;
  644. _item.employee_id = item.employee_id;
  645. }
  646. })
  647. })
  648. }
  649. },
  650. },
  651. // 监听属性 类似于data概念
  652. computed: {},
  653. // 监控data中的数据变化
  654. watch: {},
  655. beforeCreate() {}, // 生命周期 - 创建之前
  656. beforeMount() {}, // 生命周期 - 挂载之前
  657. beforeUpdate() {}, // 生命周期 - 更新之前
  658. updated() {}, // 生命周期 - 更新之后
  659. beforeDestroy() {}, // 生命周期 - 销毁之前
  660. destroyed() {}, // 生命周期 - 销毁完成
  661. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  662. };
  663. </script>
  664. <style lang="scss" scoped>
  665. .pageSlotStyle {
  666. display: flex;
  667. justify-content: center;
  668. margin-top: 50px;
  669. }
  670. /deep/ .ivu-table-wrapper {
  671. overflow: visible;
  672. }
  673. .main{
  674. height:600px;
  675. }
  676. </style>