Dispatching.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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="handleDispatchAllOpen"
  16. type="primary"
  17. style="margin-right:10px;"
  18. >全部派工</Button
  19. >
  20. </Toptitle>
  21. <div class="body">
  22. <div class="header">
  23. <Tabs v-model="currencyTag" @on-click="handleProcedureChange">
  24. <TabPane
  25. v-for="item in basicsProcedureList"
  26. :key="item.id"
  27. :label="item.title"
  28. :name="item.id + ''"
  29. />
  30. </Tabs>
  31. </div>
  32. <div class="content">
  33. <Table
  34. :columns="tableColumns"
  35. border
  36. max-height="700"
  37. @on-selection-change="handleSelectionChange"
  38. :data="tableData"
  39. >
  40. <template slot="slotGroup" slot-scope="{ row, index }">
  41. <Select
  42. v-model="row.employee_id"
  43. size="small"
  44. @on-change="
  45. (e) =>
  46. handleGroupSelect(
  47. e,
  48. tableData[index],
  49. index,
  50. tableData[index].employee_id
  51. )
  52. "
  53. clearable
  54. style="width: 150px"
  55. >
  56. <Option
  57. v-for="sitem in groupList"
  58. :key="sitem.id"
  59. :label="sitem.nickname"
  60. :value="sitem.id"
  61. >
  62. </Option>
  63. </Select>
  64. </template>
  65. <template slot="slotSet" slot-scope="{ row, index }">
  66. <a style="margin:0 5px" @click="handleSet(row, index)">详情</a>
  67. <a style="margin:0 5px" @click="handleDispatchConfirm(row, index)"
  68. >派工</a
  69. >
  70. </template>
  71. </Table>
  72. <!-- <div class="pageSlotStyle">
  73. <Page :page-size-opts="[10, 20, 30, 40,100,1000]"
  74. @on-page-size-change='changeSize'
  75. @on-change='changePage'
  76. :current='page_index'
  77. show-total
  78. :total="total"
  79. show-sizer
  80. :page-size='page_size' />
  81. </div> -->
  82. </div>
  83. </div>
  84. <Modal v-model="showModal" title="确认派工">
  85. <Form :label-width="85" ref="forms" :model="dispatchInfo">
  86. <FormItem label="选择时间">
  87. <DatePicker
  88. :options="options"
  89. style="width:100%;"
  90. v-model="dispatchTime"
  91. clearable
  92. type="daterange"
  93. split-panels
  94. placeholder="请选择日期"
  95. ></DatePicker>
  96. </FormItem>
  97. <FormItem label="点工单形式">
  98. <RadioGroup v-model="dispatchInfo.work_type">
  99. <Radio :label="1">是</Radio>
  100. <Radio :label="0">否</Radio>
  101. </RadioGroup>
  102. </FormItem>
  103. <FormItem label="日薪" v-if="dispatchInfo.work_type == 1">
  104. <Input v-model="dispatchInfo.user_salary">
  105. <span slot="append">元</span>
  106. </Input>
  107. </FormItem>
  108. </Form>
  109. <div slot="footer">
  110. <Button @click="showModal = false">取消</Button>
  111. <Button type="primary" @click="handleDispatch(subArr, subUrl)"
  112. >确认</Button
  113. >
  114. </div>
  115. </Modal>
  116. <Modal v-model="showModalAll" title="全部派工">
  117. <Table
  118. :columns="modalTableColumns"
  119. border
  120. max-height="700"
  121. :data="modalTableData"
  122. >
  123. <template slot="slotGroup" slot-scope="{ row, index }">
  124. <Select
  125. v-model="row.employee_id"
  126. size="small"
  127. @on-change="
  128. (e) =>
  129. handleGroupSelect(
  130. e,
  131. modalTableData[index],
  132. index,
  133. modalTableData[index].employee_id
  134. )
  135. "
  136. clearable
  137. style="width: 120px"
  138. >
  139. <Option
  140. v-for="sitem in groupList"
  141. :key="sitem.id"
  142. :label="sitem.nickname"
  143. :value="sitem.id"
  144. >
  145. </Option>
  146. </Select>
  147. </template>
  148. </Table>
  149. <div slot="footer">
  150. <Button @click="showModalAll = false">取消</Button>
  151. <Button type="primary" @click="handleDispatchAllConfirm">确认</Button>
  152. </div>
  153. </Modal>
  154. </div>
  155. </template>
  156. <script>
  157. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  158. // 例如:import 《组件名称》 from '《组件路径》';
  159. export default {
  160. name: "",
  161. components: {},
  162. props: {},
  163. // import引入的组件需要注入到对象中才能使用
  164. data() {
  165. // 这里存放数据
  166. return {
  167. tableColumns: [
  168. // { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  169. { title: "工序", align: "center", key: "title", minWidth: 150 },
  170. { title: "部件总数", align: "center", key: "num", minWidth: 150 },
  171. {
  172. title: "班组",
  173. align: "center",
  174. key: "",
  175. minWidth: 150,
  176. slot: "slotGroup",
  177. },
  178. {
  179. title: "操作",
  180. align: "center",
  181. key: "",
  182. minWidth: 100,
  183. slot: "slotSet",
  184. },
  185. ],
  186. modalTableColumns: [
  187. { title: "工序", align: "center", key: "title", minWidth: 150 },
  188. { title: "部件总数", align: "center", key: "num", minWidth: 150 },
  189. {
  190. title: "班组",
  191. align: "center",
  192. key: "",
  193. minWidth: 150,
  194. slot: "slotGroup",
  195. },
  196. ],
  197. modalTableData: [{}],
  198. tableData: [{}],
  199. page_index: 1,
  200. page_size: 10,
  201. total: 0,
  202. basicsProcedureList: [],
  203. groupList: [],
  204. currencyTag: "1",
  205. dispatchTime: [],
  206. selected: [],
  207. showModal: false,
  208. showModalAll: false,
  209. options: {
  210. disabledDate(date) {
  211. return date && date.valueOf() < Date.now() - 86400000;
  212. },
  213. },
  214. dispatchInfo: {},
  215. subArr: [],
  216. subUrl: "",
  217. };
  218. },
  219. // 生命周期 - 创建完成(可以访问当前this实例)
  220. created() {
  221. // 获取工序分类列表
  222. this.axios({ method: "get", url: "/api/basics_procedure_index" })
  223. .then((res) => {
  224. (this.basicsProcedureList = res.data.data),
  225. (this.currencyTag =
  226. localStorage.getItem("dispatchTag") || this.currencyTag + "");
  227. })
  228. .catch((err) => {});
  229. //获取班组列表
  230. this.axios("/api/employee_list", { params: { type: 3 } }).then(
  231. (res) => (this.groupList = res.data)
  232. );
  233. },
  234. // 生命周期 - 挂载完成(可以访问DOM元素)
  235. mounted() {
  236. this.initData();
  237. },
  238. methods: {
  239. initData() {
  240. this.axios({
  241. method: "get",
  242. url: "/api/order_produce_list",
  243. params: {
  244. basics_procedure_id:
  245. localStorage.getItem("dispatchTag") || this.currencyTag,
  246. },
  247. })
  248. .then((res) => {
  249. this.tableData = res.data;
  250. this.tableData.forEach((element) => {
  251. element.produce_id = element.id;
  252. element.employee_id ? "" : (element.employee_id = "");
  253. });
  254. this.$forceUpdate();
  255. })
  256. .catch((err) => {});
  257. },
  258. goBack() {
  259. this.$router.go(-1);
  260. },
  261. handleGoPage() {
  262. this.$router.push({ path: "/cms/Dispatching/DispatchedList" });
  263. },
  264. handleSet(row, index) {
  265. this.$router.push({
  266. path: "/cms/Dispatching/DispatchingDetail",
  267. query: {
  268. produce_id: row.id,
  269. },
  270. });
  271. },
  272. handleDispatchConfirm(row, index) {
  273. if (row.employee_id) {
  274. this.selected = [row];
  275. this.showModal = true;
  276. this.subArr = JSON.parse(JSON.stringify(this.selected));
  277. this.subUrl = "/api/order_produce_pull_all";
  278. } else {
  279. this.$Message.warning("请选择班组");
  280. }
  281. },
  282. handleDispatch(target, url) {
  283. if (!this.dispatchTime[0]) {
  284. this.$Message.warning("请选择时间");
  285. } else {
  286. this.dispatchInfo.start_time = new Date(this.dispatchTime[0])
  287. .toLocaleDateString()
  288. .replace(/\//g, "-");
  289. this.dispatchInfo.end_time = new Date(this.dispatchTime[1])
  290. .toLocaleDateString()
  291. .replace(/\//g, "-");
  292. target.forEach((element) => {
  293. element.start_time = this.dispatchInfo.start_time;
  294. element.end_time = this.dispatchInfo.end_time;
  295. element.work_type = this.dispatchInfo.work_type;
  296. element.user_salary = this.dispatchInfo.user_salary || "";
  297. });
  298. this.axios({
  299. method: "post",
  300. url,
  301. data: {
  302. ...target,
  303. },
  304. })
  305. .then((res) => {
  306. if (res.code == 200) {
  307. this.showModal = false;
  308. this.$Message.success(res.msg || "操作成功");
  309. this.initData();
  310. this.dispatchInfo = {};
  311. this.dispatchTime = [];
  312. }
  313. })
  314. .catch((err) => {});
  315. }
  316. },
  317. handleDispatchAllConfirm() {
  318. let flag = true;
  319. this.modalTableData.forEach((element) => {
  320. if (!element.employee_id || element.employee_id <= 0) {
  321. flag = false;
  322. }
  323. });
  324. if (flag) {
  325. (this.showModalAll = false), (this.showModal = true);
  326. this.subArr = JSON.parse(JSON.stringify(this.modalTableData));
  327. this.subUrl = "/api/all_order_produce_pull";
  328. } else {
  329. this.$Message.warning("请选择班组");
  330. }
  331. },
  332. handleDispatchAllOpen() {
  333. console.log(localStorage.getItem("dispatchTag"));
  334. console.log("this.currencyTag :>> ", this.currencyTag);
  335. this.axios
  336. .get("/api/get_all_order_produce", {
  337. params: {
  338. basics_procedure_id:
  339. localStorage.getItem("dispatchTag") | this.currencyTag,
  340. },
  341. })
  342. .then((res) => {
  343. if (res.code == 200) {
  344. this.modalTableData = res.data;
  345. this.modalTableData.forEach((element) => {
  346. element.produce_id = element.id;
  347. });
  348. this.showModalAll = true;
  349. }
  350. });
  351. },
  352. changePage(e) {
  353. this.page_index = e;
  354. this.initData();
  355. },
  356. changeSize(e) {
  357. this.page_size = e;
  358. this.initData();
  359. },
  360. handleProcedureChange(val) {
  361. this.selected = [];
  362. this.currencyTag = val;
  363. localStorage.setItem("dispatchTag", val);
  364. this.initData();
  365. },
  366. handleSelectionChange(selection) {
  367. this.selected = selection;
  368. },
  369. handleGroupSelect(e, row, index, value) {
  370. // if (this.selected.length > 0) {
  371. // this.selected.forEach(element => {
  372. // if (element.id == row.id) {
  373. // element.employee_id = value
  374. // }
  375. // });
  376. // }
  377. row.employee_id = e;
  378. },
  379. },
  380. // 监听属性 类似于data概念
  381. computed: {},
  382. // 监控data中的数据变化
  383. watch: {},
  384. beforeCreate() {}, // 生命周期 - 创建之前
  385. beforeMount() {}, // 生命周期 - 挂载之前
  386. beforeUpdate() {}, // 生命周期 - 更新之前
  387. updated() {}, // 生命周期 - 更新之后
  388. beforeDestroy() {}, // 生命周期 - 销毁之前
  389. destroyed() {}, // 生命周期 - 销毁完成
  390. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  391. };
  392. </script>
  393. <style lang="scss" scoped>
  394. .pageSlotStyle {
  395. display: flex;
  396. justify-content: center;
  397. margin-top: 40px;
  398. }
  399. /deep/ .ivu-table-wrapper {
  400. overflow: visible;
  401. }
  402. </style>