index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <template>
  2. <div class="index_box">
  3. <div class="c_header_title">
  4. <!-- <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
  5. <el-tab-pane label="委外记录" name="1"></el-tab-pane>
  6. <el-tab-pane label="请托记录" name="2"></el-tab-pane>
  7. </el-tabs> -->
  8. <div class="c_title">委外记录</div>
  9. </div>
  10. <div style="overflow: auto">
  11. <el-form
  12. label-width="100px"
  13. :rules="rules"
  14. ref="form"
  15. :model="attributeData"
  16. >
  17. <el-form-item label="委外名称:" prop="name">
  18. <el-input
  19. placeholder=""
  20. v-model="attributeData.name"
  21. style="width: 260px"
  22. ></el-input>
  23. </el-form-item>
  24. <el-form-item label="委外类型:" prop="type">
  25. <el-select
  26. v-model="attributeData.type"
  27. placeholder="请选择"
  28. style="width: 260px"
  29. >
  30. <el-option
  31. v-for="item in typeList"
  32. :key="item.id"
  33. :label="item.name"
  34. :value="item.id"
  35. >
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="委外数量:" prop="formedNumLast">
  40. <el-input
  41. placeholder="请输入委外数量"
  42. type="number"
  43. v-model="attributeData.formedNumLast"
  44. style="width: 260px"
  45. ></el-input>
  46. </el-form-item>
  47. <el-form-item label="委外工序:" prop="taskIdes">
  48. <el-select
  49. v-model="attributeData.taskIdes"
  50. placeholder="请选择"
  51. style="width: 260px"
  52. @change="changeTaskId"
  53. multiple
  54. >
  55. <el-option
  56. v-for="item in newStepsList"
  57. :key="item.taskId"
  58. :label="item.taskTypeName"
  59. :value="item.taskId"
  60. >
  61. </el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="委外场景:" prop="sceneText">
  65. <el-input
  66. placeholder=""
  67. v-model="attributeData.sceneText"
  68. disabled
  69. style="width: 260px"
  70. ></el-input>
  71. </el-form-item>
  72. <!-- v-if="attributeData.isFirstTask != 1" -->
  73. <el-form-item label="直接入库:" borderBottom prop="warehouseId">
  74. <div style="display: flex">
  75. <div
  76. style="font-size: 15px"
  77. v-if="attributeData.clientEnvironmentId == 2"
  78. >是</div
  79. >
  80. <!-- <el-checkbox-group v-model="isInWarehouse" size="15px" v-if="attributeData.clientEnvironmentId != 2 ">
  81. <el-checkbox labelSize="15px" iconSize="10px" activeColor="#157A2C" name="true"
  82. label="是"></el-checkbox>
  83. </el-checkbox-group> -->
  84. <!-- <el-checkbox labelSize="15px" iconSize="10px" v-model="isInWarehouse" activeColor="#157A2C" name="true"
  85. label="是" v-if="attributeData.clientEnvironmentId != 2 "></el-checkbox> -->
  86. <el-select
  87. v-if="attributeData.clientEnvironmentId == 2 || isInWarehouse"
  88. v-model="attributeData.warehouseId"
  89. placeholder="请选择"
  90. style="width: 260px"
  91. >
  92. <el-option
  93. v-for="item in warehouseList"
  94. :key="item.id"
  95. :label="item.name"
  96. :value="item.id"
  97. >
  98. </el-option>
  99. </el-select>
  100. </div>
  101. </el-form-item>
  102. <el-form-item label="委外单位:">
  103. <el-select
  104. v-model="attributeData.supplierId"
  105. placeholder="请选择"
  106. style="width: 260px"
  107. @change="changeTaskId"
  108. filterable
  109. >
  110. <el-option
  111. v-for="(item, index) in gysList"
  112. :key="item.id + index"
  113. :value="item.id"
  114. :label="item.name"
  115. ></el-option>
  116. </el-select>
  117. </el-form-item>
  118. <el-form-item
  119. label="工艺路线:"
  120. borderBottom
  121. style="font-size: 15px"
  122. prop="produceRoutingId"
  123. v-if="
  124. attributeData.clientEnvironmentId != 2 &&
  125. attributeData.isFirstTask != 1 &&
  126. isInWarehouse &&
  127. isInWarehouse.length == 0
  128. "
  129. >
  130. <el-select
  131. v-model="attributeData.produceRoutingId"
  132. placeholder="请选择"
  133. style="width: 260px"
  134. >
  135. <el-option
  136. v-for="item in produceList"
  137. :key="item.id"
  138. :label="item.name"
  139. :value="item.id"
  140. >
  141. </el-option>
  142. </el-select>
  143. </el-form-item>
  144. <el-form-item label="交付交期:" prop="requireDeliveryTime">
  145. <el-date-picker
  146. v-model="attributeData.requireDeliveryTime"
  147. value-format="yyyy-MM-dd HH:mm:ss"
  148. style="width: 260px"
  149. type="date"
  150. placeholder="选择日期"
  151. >
  152. </el-date-picker>
  153. </el-form-item>
  154. <el-form-item label="生产备注:">
  155. <el-input
  156. type="textarea"
  157. :autosize="{ minRows: 2, maxRows: 4 }"
  158. placeholder="请输入内容"
  159. v-model="textarea2"
  160. style="width: 260px"
  161. >
  162. </el-input>
  163. </el-form-item>
  164. <div class="btn-box">
  165. <el-button type="primary" @click="confirm">确认</el-button>
  166. <el-button type="primary" @click="cancel">取消</el-button>
  167. </div>
  168. </el-form>
  169. </div>
  170. <div v-if="activeName == '2'">
  171. <el-form
  172. label-width="100px"
  173. :rules="rules"
  174. ref="form"
  175. :model="attributeData"
  176. >
  177. <el-form-item label="请托名称:" prop="name">
  178. <el-input
  179. placeholder=""
  180. v-model="attributeData.name"
  181. style="width: 260px"
  182. ></el-input>
  183. </el-form-item>
  184. <el-form-item label="请托类型:" prop="type">
  185. <el-select
  186. v-model="attributeData.type"
  187. placeholder="请选择"
  188. style="width: 260px"
  189. >
  190. <el-option
  191. v-for="item in pleaseList"
  192. :key="item.id"
  193. :label="item.name"
  194. :value="item.id"
  195. >
  196. </el-option>
  197. </el-select>
  198. </el-form-item>
  199. <el-form-item label="请托数量:" prop="formedNumLast">
  200. <el-input
  201. placeholder="请输入请托数量"
  202. type="number"
  203. v-model="attributeData.formedNumLast"
  204. style="width: 260px"
  205. ></el-input>
  206. </el-form-item>
  207. <el-form-item label="请托到:" prop="taskIdes">
  208. <el-select
  209. v-model="attributeData.taskIdes"
  210. placeholder="请选择"
  211. style="width: 260px"
  212. @change="changeTaskId"
  213. multiple
  214. >
  215. <el-option
  216. v-for="item in newStepsList"
  217. :key="item.taskId"
  218. :label="item.taskTypeName"
  219. :value="item.taskId"
  220. >
  221. </el-option>
  222. </el-select>
  223. </el-form-item>
  224. <el-form-item label="请托场景:" prop="sceneText">
  225. <el-input
  226. placeholder=""
  227. v-model="attributeData.sceneText"
  228. disabled
  229. style="width: 260px"
  230. ></el-input>
  231. </el-form-item>
  232. <!-- v-if="attributeData.isFirstTask != 1" -->
  233. <el-form-item label="直接入库:" borderBottom prop="warehouseId">
  234. <div style="display: flex">
  235. <div
  236. style="font-size: 15px"
  237. v-if="attributeData.clientEnvironmentId == 2"
  238. >是</div
  239. >
  240. <!-- <el-checkbox-group v-model="isInWarehouse" size="15px" v-if="attributeData.clientEnvironmentId != 2 ">
  241. <el-checkbox labelSize="15px" iconSize="10px" activeColor="#157A2C" name="true"
  242. label="是"></el-checkbox>
  243. </el-checkbox-group> -->
  244. <!-- <el-checkbox labelSize="15px" iconSize="10px" v-model="isInWarehouse" activeColor="#157A2C" name="true"
  245. label="是" v-if="attributeData.clientEnvironmentId != 2 "></el-checkbox> -->
  246. <el-select
  247. v-if="attributeData.clientEnvironmentId == 2 || isInWarehouse"
  248. v-model="attributeData.warehouseId"
  249. placeholder="请选择"
  250. style="width: 260px"
  251. >
  252. <el-option
  253. v-for="item in warehouseList"
  254. :key="item.id"
  255. :label="item.name"
  256. :value="item.id"
  257. >
  258. </el-option>
  259. </el-select>
  260. </div>
  261. </el-form-item>
  262. <el-form-item label="请托单位:">
  263. <el-select
  264. v-model="attributeData.factoriesId"
  265. placeholder="请选择"
  266. style="width: 260px"
  267. @change="changeTaskId"
  268. >
  269. <el-option
  270. v-for="item in factoryList"
  271. :key="item.factoryId"
  272. :label="item.factoryName"
  273. :value="item.factoryId"
  274. >
  275. </el-option>
  276. </el-select>
  277. </el-form-item>
  278. <el-form-item
  279. label="工艺路线:"
  280. borderBottom
  281. style="font-size: 15px"
  282. prop="produceRoutingId"
  283. v-if="
  284. attributeData.clientEnvironmentId != 2 &&
  285. attributeData.isFirstTask != 1 &&
  286. isInWarehouse &&
  287. isInWarehouse.length == 0
  288. "
  289. >
  290. <el-select
  291. v-model="attributeData.produceRoutingId"
  292. placeholder="请选择"
  293. style="width: 260px"
  294. >
  295. <el-option
  296. v-for="item in produceList"
  297. :key="item.id"
  298. :label="item.name"
  299. :value="item.id"
  300. >
  301. </el-option>
  302. </el-select>
  303. </el-form-item>
  304. <el-form-item label="交付交期:" prop="requireDeliveryTime">
  305. <el-date-picker
  306. v-model="attributeData.requireDeliveryTime"
  307. value-format="yyyy-MM-dd"
  308. style="width: 260px"
  309. type="date"
  310. placeholder="选择日期"
  311. >
  312. </el-date-picker>
  313. </el-form-item>
  314. <el-form-item label="生产备注:">
  315. <el-input
  316. type="textarea"
  317. :autosize="{ minRows: 2, maxRows: 4 }"
  318. placeholder="请输入内容"
  319. v-model="textarea2"
  320. style="width: 260px"
  321. >
  322. </el-input>
  323. </el-form-item>
  324. </el-form>
  325. <div class="btn-box">
  326. <el-button type="primary" @click="confirm">确认</el-button>
  327. </div>
  328. </div>
  329. </div>
  330. </template>
  331. <script>
  332. import { getWarehouseList, producerouting } from '@/api/produce/index.js';
  333. import { contactList } from '@/api/produce/bom.js';
  334. import { getFactoryarea } from '@/api/aps';
  335. export default {
  336. components: {},
  337. data() {
  338. return {
  339. attributeData: {
  340. name: '',
  341. type: '', //类型
  342. sceneText: '', //场景
  343. formedNumLast: '', //数据
  344. taskIds: '', //委外到
  345. isFirstTask: '',
  346. clientEnvironmentId: 1, //直接入库
  347. requireDeliveryTime: '', //计划交期
  348. warehouseId: '', //仓库id
  349. produceRoutingId: '', //工艺路线id
  350. supplierId: '', //供应商id
  351. supplierName: '',
  352. taskIdes: [],
  353. factoriesId: '',
  354. factoriesName: ''
  355. },
  356. isInWarehouse: true,
  357. produceList: [],
  358. warehouseList: [],
  359. newStepsList: [],
  360. taskIds: '',
  361. typeList: [
  362. {
  363. id: 4,
  364. name: '带料生产委外'
  365. },
  366. {
  367. id: 5,
  368. name: '不带料生产委外'
  369. }
  370. ],
  371. pleaseList: [
  372. {
  373. id: 4,
  374. name: '带料生产请托'
  375. },
  376. {
  377. id: 5,
  378. name: '不带料生产请托'
  379. }
  380. ],
  381. rules: {
  382. name: [
  383. { required: true, message: '请输入委外名称', trigger: 'blur' }
  384. ],
  385. type: [
  386. { required: true, message: '请选择委外类型', trigger: 'blur' }
  387. ],
  388. formedNumLast: [
  389. { required: true, message: '请输入委外数量', trigger: 'blur' }
  390. ],
  391. taskIdes: [
  392. { required: true, message: '请选择委外工序', trigger: 'blur' }
  393. ],
  394. sceneText: [
  395. { required: true, message: '请选择委外场景', trigger: 'blur' }
  396. ],
  397. warehouseId: [{ required: true, message: '请选择', trigger: 'blur' }],
  398. requireDeliveryTime: [
  399. { required: true, message: '请选择计划交期时间', trigger: 'blur' }
  400. ]
  401. },
  402. loading: false,
  403. operationType: null,
  404. workListIds: [],
  405. activeName: '1',
  406. textarea2: '',
  407. gysList: [],
  408. factoryList: [],
  409. clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId
  410. };
  411. },
  412. props: {
  413. outsourceFormVal: {
  414. type: Object,
  415. default: () => ({})
  416. },
  417. taskName: {
  418. type: String,
  419. default: ''
  420. }
  421. },
  422. watch: {
  423. outsourceFormVal: {
  424. handler(val) {
  425. console.log(val, 'outsourceForm');
  426. Object.assign(this.attributeData, val);
  427. // console.log(this.attributeData.newStepsList, 'attributeData');
  428. // this.newStepsList = this.attributeData.newStepsList.filter(
  429. // (item) => item.type != 2 && item.type != 3 && item.type != 6
  430. // );
  431. if (this.clientEnvironmentId == 3) {
  432. if (
  433. this.attributeData.newStepsList &&
  434. this.attributeData.newStepsList.length != 0
  435. ) {
  436. this.newStepsList = this.attributeData.newStepsList.filter(
  437. (item) => item.type != 6
  438. );
  439. }
  440. } else {
  441. this.newStepsList = this.attributeData.newStepsList;
  442. }
  443. this.getWarehouseFn();
  444. this.produceFn();
  445. },
  446. deep: true,
  447. immediate: true
  448. }
  449. },
  450. computed: {
  451. taskObj() {
  452. return this.$store.state.user.taskObj;
  453. }
  454. },
  455. mounted() {
  456. this.getContactList();
  457. this.getFactoryList();
  458. // if (this.activeName == '1') {
  459. // // this.attributeData.name = this.outsourceFormVal.name + '委托';
  460. // this.$set(this.outsourceFormVal, 'name', this.taskName + '委托');
  461. // } else if (this.activeName == '2') {
  462. // // this.attributeData.name = this.outsourceFormVal.name + '请托';
  463. // this.$set(this.outsourceFormVal, 'name', this.taskName + '请托');
  464. // }
  465. },
  466. methods: {
  467. // 工艺路线
  468. produceFn() {
  469. let param = {
  470. pageNum: 1,
  471. size: -1,
  472. routeType: 2
  473. };
  474. producerouting(param).then((res) => {
  475. this.produceList = res.list;
  476. });
  477. },
  478. async getFactoryList() {
  479. let par = {
  480. type: 1,
  481. size: 9999
  482. };
  483. await getFactoryarea(par).then((res) => {
  484. console.log(res, '工厂数据');
  485. if (res.list && res.list.length > 0) {
  486. console.log(res.list, '工厂数据');
  487. this.factoryList = res.list;
  488. // this.factoryList = res.list.map((el) => {
  489. // return {
  490. // value: el.factoryId,
  491. // label: el.factoryName
  492. // };
  493. // });
  494. }
  495. });
  496. console.log(this.factoryList, '工厂数据111');
  497. },
  498. async getContactList() {
  499. let param = {
  500. pageNum: 1,
  501. type: 2,
  502. size: -1,
  503. status: 1
  504. };
  505. await contactList(param).then((res) => {
  506. this.gysList = res.list;
  507. });
  508. console.log(this.gysList, '供应商数据');
  509. },
  510. handleClick(tab, event) {
  511. this.activeName = tab._props.name;
  512. if (this.activeName == '1') {
  513. this.resetData();
  514. this.attributeData.name = this.taskName + '委托';
  515. } else if (this.activeName == '2') {
  516. this.resetData();
  517. this.attributeData.name = this.taskName + '请托';
  518. }
  519. },
  520. // 仓库
  521. getWarehouseFn() {
  522. getWarehouseList().then((res) => {
  523. // console.log(
  524. // this.$store.state.user.info.factoryId,
  525. // 'this.$store.state.user.info'
  526. // );
  527. // console.log(res, '仓库数据');
  528. this.warehouseList = res.data.filter(
  529. (item) => item.factoryId == this.$store.state.user.info.factoryId
  530. );
  531. // console.log(this.warehouseList, '数据');
  532. // console.log(res, '仓库数据');
  533. // this.warehouseList = res.data;
  534. });
  535. },
  536. changeTaskId(e) {
  537. console.log(e);
  538. const arr = this.newStepsList.find((item) => item.taskId === e);
  539. if (this.attributeData.taskIdes.length != 0) {
  540. if (this.attributeData.taskIdes.length == 1) {
  541. this.attributeData.sceneText = '单工序';
  542. this.attributeData.outsourceScene = 2;
  543. } else {
  544. this.attributeData.sceneText = '多工序';
  545. this.attributeData.outsourceScene = 3;
  546. }
  547. // const id = this.newStepsList[0].sourceTaskId;
  548. // if (this.attributeData.isFirstTask) {
  549. // this.attributeData.sceneText = '首工序';
  550. // this.attributeData.outsourceScene = 1;
  551. // if (arr.sourceTaskId !== id) {
  552. // this.attributeData.sceneText = '首工序及多工序';
  553. // this.attributeData.outsourceScene = 4;
  554. // }
  555. // } else {
  556. // if (arr.sourceTaskId === id) {
  557. // // 单工序
  558. // this.attributeData.sceneText = '单工序';
  559. // this.attributeData.outsourceScene = 2;
  560. // } else {
  561. // //多工序
  562. // this.attributeData.sceneText = '多工序';
  563. // this.attributeData.outsourceScene = 3;
  564. // }
  565. // }
  566. } else {
  567. this.attributeData.sceneText = '';
  568. this.attributeData.outsourceScene = '';
  569. // uni.showToast({
  570. // title: '委外到工序为空',
  571. // icon: 'none'
  572. // });
  573. }
  574. },
  575. resetData() {
  576. this.attributeData.type = '';
  577. this.attributeData.sceneText = '';
  578. this.attributeData.taskIds = '';
  579. this.attributeData.isFirstTask = '';
  580. this.attributeData.clientEnvironmentId = 1;
  581. this.attributeData.requireDeliveryTime = '';
  582. this.attributeData.warehouseId = '';
  583. this.attributeData.produceRoutingId = '';
  584. this.attributeData.supplierId = '';
  585. this.attributeData.taskIdes = [];
  586. this.attributeData.factoriesId = '';
  587. },
  588. //跳转
  589. confirm() {
  590. this.$refs.form.validate((valid) => {
  591. if (valid) {
  592. // if (this.activeName == '1') {
  593. if (this.attributeData.supplierId) {
  594. const obj = this.gysList.find(
  595. (item) => item.id === this.attributeData.supplierId
  596. );
  597. this.attributeData.supplierName = obj ? obj.name : '';
  598. }
  599. this.attributeData.taskIds = this.attributeData.taskIdes.join(',');
  600. this.$emit('changePlugIn', this.attributeData, this.activeName);
  601. // } else if (this.activeName == '2') {
  602. // const obj = this.factoryList.find(
  603. // (item) => item.id === this.attributeData.factoriesId
  604. // );
  605. // this.attributeData.factoriesName = obj ? obj.name : '';
  606. // this.attributeData.taskIds =
  607. // this.attributeData.taskIdes.join(',');
  608. // console.log(this.attributeData);
  609. // this.$emit('changePlugIn', this.attributeData, this.activeName);
  610. // }
  611. } else {
  612. console.log('error submit!!');
  613. return false;
  614. }
  615. });
  616. },
  617. cancel() {
  618. this.$emit('changeCancel');
  619. }
  620. },
  621. created() {
  622. this.operationType = null;
  623. this.workListIds = [];
  624. }
  625. };
  626. </script>
  627. <style scoped>
  628. .index_box {
  629. padding: 0 !important;
  630. overflow: auto;
  631. }
  632. .c_header_title {
  633. display: flex;
  634. align-items: center;
  635. margin-bottom: 0;
  636. padding-left: 20px;
  637. height: 52px;
  638. margin-bottom: 10px;
  639. box-sizing: border-box;
  640. background: var(--table-header-background-color);
  641. border-bottom: 1px solid var(--border-color-lighter);
  642. }
  643. .c_title {
  644. color: #157a2c;
  645. font-size: 16px;
  646. font-weight: bold;
  647. }
  648. .btn-box {
  649. margin-left: 50px;
  650. }
  651. ::v-deep .el-select__tags {
  652. flex-wrap: nowrap;
  653. overflow: auto;
  654. }
  655. /* 输入框最大宽度*/
  656. ::v-deep .el-select__tags-text {
  657. max-width: 90px;
  658. }
  659. /* 底部滚动条的高度*/
  660. ::v-deep .el-select__tags::-webkit-scrollbar {
  661. height: 2px !important;
  662. }
  663. </style>