detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <div class="BidSystemProductDeOrderEdit">
  3. <Toptitle title="拆单页">
  4. <slot name="titleButton">
  5. <Upload
  6. style="display:inline"
  7. name="your_file"
  8. :show-upload-list="false"
  9. :data="uploadData"
  10. :headers="headers"
  11. :on-error="uploadError"
  12. :before-upload="handleBeforeUpload"
  13. :on-success="uploadImportSuccess"
  14. :action="$store.state.ip + '/api/explode_save_import'"
  15. >
  16. <Button type="success" ghost icon="md-exit" style="margin-right:10px;"
  17. >导入</Button
  18. >
  19. </Upload>
  20. <Button
  21. @click="handleFinish(0)"
  22. type="primary"
  23. style="margin-right: 10px"
  24. >取消完成</Button
  25. >
  26. <Button
  27. @click="handleFinish(1)"
  28. type="primary"
  29. style="margin-right: 10px"
  30. >完成</Button
  31. >
  32. <Button
  33. @click="showSupModal = true"
  34. type="primary"
  35. style="margin-right:10px;"
  36. >项目辅料</Button
  37. >
  38. <Button
  39. @click="goback()"
  40. type="primary"
  41. ghost
  42. style="margin-right:10px;"
  43. >返回</Button
  44. >
  45. <!-- <Button
  46. @click="postData()"
  47. type="primary"
  48. ghost
  49. style="margin-right:10px;"
  50. >保存</Button
  51. > -->
  52. </slot>
  53. </Toptitle>
  54. <div class="top_search_info">
  55. <Form inline :label-width="100">
  56. <FormItem label="产品名称:">
  57. <Input
  58. type="text"
  59. size="small"
  60. clearable
  61. v-model="searchData.title"
  62. placeholder="请输入产品名称"
  63. />
  64. </FormItem>
  65. <FormItem label="图号:">
  66. <Input
  67. type="text"
  68. size="small"
  69. clearable
  70. v-model="searchData.url_number"
  71. style="width: 150px"
  72. placeholder="请输入图号"
  73. />
  74. </FormItem>
  75. <FormItem label="是否完成:">
  76. <Select
  77. v-model="searchData.status"
  78. size="small"
  79. clearable
  80. filterable
  81. style="width: 150px"
  82. >
  83. <Option label="是" :value="1"></Option>
  84. <Option label="否" :value="0"></Option>
  85. </Select>
  86. </FormItem>
  87. <FormItem label="是否下生产:">
  88. <Select
  89. v-model="searchData.sub_state"
  90. size="small"
  91. clearable
  92. filterable
  93. style="width: 150px"
  94. >
  95. <Option label="是" :value="1"></Option>
  96. <Option label="否" :value="0"></Option>
  97. </Select>
  98. </FormItem>
  99. <FormItem>
  100. <Button
  101. size="small"
  102. type="primary"
  103. @click="
  104. initData(
  105. formData.order_no,
  106. formData.orders_area_product_detail_id
  107. )
  108. "
  109. >搜索</Button
  110. >
  111. </FormItem>
  112. </Form>
  113. </div>
  114. <div class="top_search">
  115. <div><span>订单号:</span>{{ formData.order_no }}</div>
  116. <div><span>项目名称:</span>{{ formData.residential_name }}</div>
  117. <div><span>客户姓名:</span>{{ formData.client_name }}</div>
  118. <div>
  119. <span>紧急程度:</span
  120. ><span
  121. v-for="_item in warningList"
  122. :key="_item.id"
  123. v-show="_item.id == formData.warning_state"
  124. >{{ _item.title }}</span
  125. >
  126. </div>
  127. <div>
  128. <span>收款:</span>{{ formData.pay_state == 1 ? "已收款" : "未收款" }}
  129. </div>
  130. <div><span>详细地址:</span>{{ formData.address }}</div>
  131. <div><span>手机号:</span>{{ formData.mobile }}</div>
  132. <div>
  133. <span>开始日期:</span>{{ func.replaceDate(formData.start_time) }}
  134. </div>
  135. <div><span>交付日期:</span>{{ func.replaceDate(formData.end_time) }}</div>
  136. <div>
  137. <span>业务员:</span>
  138. <span
  139. v-for="item in salesmanList"
  140. :key="item.id"
  141. v-show="formData.salesman == item.id"
  142. >{{ formData.salesman }}</span
  143. >
  144. </div>
  145. <!-- <div><span>订单类型:</span>{{formData.renovation_type==1?"工装":"家装"}}</div> -->
  146. <div><span>备注:</span>{{ formData.remark }}</div>
  147. </div>
  148. <div class="addArea">
  149. <div class="addAreaTable">
  150. <Table
  151. :columns="tableColumns"
  152. :data="formData.detail"
  153. border
  154. @on-selection-change="changeSelection"
  155. >
  156. <template slot="set" slot-scope="{ row, index }">
  157. <a
  158. :disabled="row.explode_status != 0"
  159. style="margin:0 5px"
  160. @click="handleSet(row, index, 1)"
  161. >拆单</a
  162. >
  163. <a
  164. :disabled="row.explode_status == 0"
  165. style="margin:0 5px"
  166. @click="handleSet(row, index, 3)"
  167. >变更</a
  168. >
  169. <a style="margin:0 5px" @click="handleSet(row, index, 2)">详情</a>
  170. </template>
  171. </Table>
  172. </div>
  173. </div>
  174. <!-- 项目辅料弹窗 -->
  175. <Modal title="项目辅料" v-model="showSupModal" :width="400">
  176. <div>
  177. <div class="supModalBtn">
  178. <!-- <Button @click="handleAddSup" type="primary">新增</Button> -->
  179. </div>
  180. <Table :columns="supTableColumns" :data="supTableData" border>
  181. <template slot="combine" slot-scope="{ index }">
  182. <Select
  183. v-model="supTableData[index].id"
  184. @on-change="handlechange"
  185. transfer
  186. size="small"
  187. >
  188. <Option
  189. v-for="item in combineList"
  190. :value="item.id"
  191. :key="item.id"
  192. :label="item.title"
  193. ></Option>
  194. </Select>
  195. </template>
  196. <template slot="supSet" slot-scope="{ row, index }">
  197. <a
  198. style="margin: 0 5px; color: red"
  199. v-show="$route.query.type != 3"
  200. @click="handleSupSet(row, index)"
  201. >删除</a
  202. >
  203. </template>
  204. </Table>
  205. </div>
  206. <div class="modal-footer" slot="footer">
  207. <Button @click="showSupModal = false">取消</Button>
  208. <Button type="primary" @click="showSupModal = false">确认</Button>
  209. </div>
  210. </Modal>
  211. </div>
  212. </template>
  213. <script>
  214. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  215. // 例如:import 《组件名称》 from '《组件路径》';
  216. export default {
  217. name: "BidSystemProductDeOrderEdit",
  218. components: {},
  219. props: {},
  220. // import引入的组件需要注入到对象中才能使用
  221. data() {
  222. // 这里存放数据
  223. return {
  224. selection_check: "",
  225. detail_id: [],
  226. showSupModal: false,
  227. showPDTModal: false,
  228. formData: {
  229. order_no: "",
  230. orders_area_product_detail_id: "",
  231. residential_name: "",
  232. client_name: "",
  233. address: "",
  234. mobile: "",
  235. pay_state: "",
  236. warning_state: "",
  237. salesman: "",
  238. remark: "",
  239. //区域列表
  240. area: [
  241. {
  242. num: "",
  243. title: "",
  244. unit: "",
  245. quantity: "",
  246. house_type: "",
  247. remark: "",
  248. order_no: "",
  249. product: [
  250. // {
  251. // title:'',
  252. // num:'',
  253. // measure:'',
  254. // process_property:'',
  255. // url:'',
  256. // url_number:'',
  257. // remark:''
  258. // }
  259. ],
  260. },
  261. ],
  262. },
  263. product: [{}],
  264. searchData: {},
  265. tableColumns: [
  266. {
  267. type: "selection",
  268. width: 60,
  269. align: "center",
  270. },
  271. {
  272. title: "序号",
  273. type: "index",
  274. align: "center",
  275. minWidth: 80,
  276. resizable: true,
  277. },
  278. {
  279. title: "产品名称",
  280. key: "title",
  281. align: "center",
  282. minWidth: 120,
  283. resizable: true,
  284. },
  285. {
  286. title: "计量单位",
  287. key: "unit",
  288. align: "center",
  289. minWidth: 100,
  290. resizable: true,
  291. },
  292. {
  293. title: "图号",
  294. key: "url_number",
  295. align: "center",
  296. minWidth: 80,
  297. resizable: true,
  298. },
  299. {
  300. title: "数量",
  301. key: "num",
  302. align: "center",
  303. minWidth: 80,
  304. resizable: true,
  305. },
  306. {
  307. title: "规格",
  308. key: "measure",
  309. align: "center",
  310. minWidth: 140,
  311. resizable: true,
  312. },
  313. {
  314. title: "工艺属性",
  315. key: "process_property",
  316. align: "center",
  317. minWidth: 140,
  318. resizable: true,
  319. tooltip: true,
  320. },
  321. {
  322. title: "图纸",
  323. key: "url",
  324. align: "center",
  325. resizable: true,
  326. minWidth: 80,
  327. render: (h, params) => {
  328. const { row } = params;
  329. return h(
  330. "div",
  331. row.url.map((item, index) => {
  332. return h("img", {
  333. attrs: {
  334. src: this.$store.state.ip + item,
  335. style:
  336. "max-width:50px;max-height:50px;position:relative;top:3px;",
  337. },
  338. on: {
  339. click: (e) => {
  340. // this.axios('/api/orders_img', { params: { id: row.id, type: 1 } }).then(res => {
  341. // if (res.code == 200) {
  342. // row.imgs = res.data
  343. let list = [];
  344. row.url.forEach((el) => {
  345. list.push({ img_url: el });
  346. });
  347. this.$previewImg({
  348. list,
  349. baseUrl: this.$store.state.ip,
  350. baseImgField: "img_url",
  351. baseTitleField: "",
  352. });
  353. // }
  354. // })
  355. },
  356. },
  357. });
  358. })
  359. );
  360. },
  361. },
  362. {
  363. title: "左右式",
  364. key: "left_right_mode",
  365. align: "center",
  366. resizable: true,
  367. minWidth: 80,
  368. render: (h, params) => {
  369. const { row } = params;
  370. return h(
  371. "span",
  372. {},
  373. row.left_right_mode == 1
  374. ? "左式"
  375. : row.left_right_mode == 2
  376. ? "右式"
  377. : "无"
  378. );
  379. },
  380. },
  381. {
  382. title: "拆单状态",
  383. key: "status",
  384. align: "center",
  385. resizable: true,
  386. minWidth: 80,
  387. render: (h, params) => {
  388. const { row } = params;
  389. return h("span", {}, row.explode_status == 0 ? "未完成" : "已完成");
  390. },
  391. },
  392. {
  393. title: "是否下生产",
  394. key: "",
  395. align: "center",
  396. resizable: true,
  397. width: 80,
  398. render: (h, params) => {
  399. return h("span", {}, params.row.status == 0 ? "否" : "是");
  400. },
  401. },
  402. {
  403. title: "操作",
  404. key: "name",
  405. align: "center",
  406. slot: "set",
  407. minWidth: 170,
  408. // fixed: "right",
  409. resizable: true,
  410. },
  411. ],
  412. //产品分类列表
  413. PDTTypeList: [],
  414. //业务员列表
  415. salesmanList: [],
  416. headers: { Authorization: localStorage.getItem("token") },
  417. warningList: [],
  418. supTableColumns: [
  419. { title: "序号", type: "index", align: "center", minWidth: 100 },
  420. {
  421. title: "辅料名称",
  422. key: "title",
  423. align: "center",
  424. slot: "combine",
  425. minWidth: 150,
  426. },
  427. { title: "操作", align: "center", slot: "supSet", minWidth: 100 },
  428. ],
  429. supTableData: [], //项目辅料→辅料名称列表
  430. combineList: [], //项目辅料列表
  431. uploadData: {},
  432. };
  433. },
  434. // 生命周期 - 创建完成(可以访问当前this实例)
  435. created() {
  436. // 获取项目辅料列表
  437. this.axios("/api/material_combination").then((res) => {
  438. this.combineList = res.data.data;
  439. });
  440. // 2编辑 3详情 4变更 5变更记录
  441. this.$route.query.type == 3 ? (this.isChecked = true) : "";
  442. this.$route.query.order_no
  443. ? (this.formData.order_no = this.$route.query.order_no)
  444. : "";
  445. this.$route.query.orders_area_product_detail_id
  446. ? (this.formData.orders_area_product_detail_id = this.$route.query.orders_area_product_detail_id)
  447. : "";
  448. // 获取紧急程度
  449. this.axios.get("/api/warning_list").then((res) => {
  450. this.warningList = res.data.data;
  451. });
  452. // 获取项目辅料
  453. // this.axios
  454. // .get("/api/todo", { params: { order_no: this.formData.order_no } })
  455. // .then((res) => {
  456. // this.supTableData = res.data
  457. // });
  458. },
  459. // 生命周期 - 挂载完成(可以访问DOM元素)
  460. mounted() {
  461. this.axios("/api/user").then((res) => (this.salesmanList = res.data.data));
  462. this.axios("/api/parts_product_list").then((res) => {
  463. this.PDTTypeList = res.data;
  464. });
  465. this.initData(
  466. this.formData.order_no,
  467. this.formData.orders_area_product_detail_id
  468. );
  469. },
  470. methods: {
  471. changeSelection(e) {
  472. this.selection_check = e;
  473. e.forEach((item) => {
  474. this.detail_id.push(item.id);
  475. });
  476. },
  477. async handleBeforeUpload(row) {
  478. // row.name
  479. console.log("row :>> ", row);
  480. this.uploadData.order_no = this.$route.query.order_no;
  481. this.uploadData.oa_id = this.$route.query.oa_id;
  482. return true;
  483. },
  484. uploadImportSuccess(res) {
  485. if (res.code == 200) {
  486. this.$Message.success(res.msg || "上传成功");
  487. // const temp = res.data;
  488. // let list = [...this.postInfo.children, ...temp];
  489. } else {
  490. this.$Message.warning(res.msg || "上传失败");
  491. }
  492. },
  493. uploadError(err) {
  494. this.$Message.error(err.msg || "上传失败");
  495. },
  496. handleFinish(status) {
  497. if (this.selection_check.length == 0) {
  498. this.$Message.warning("请选择数据");
  499. } else {
  500. this.$Modal.confirm({
  501. title: "确认完成?",
  502. // content: "此操作确认后不可恢复,请确认!",
  503. onOk: () => {
  504. this.axios({
  505. method: "post",
  506. url: "/api/order_area_product_status",
  507. data: {
  508. status,
  509. orders_area_product_detail_id: this.detail_id,
  510. },
  511. }).then((res) => {
  512. if (res.code == 200) {
  513. this.$Message.success(res.msg);
  514. this.initData(
  515. this.formData.order_no,
  516. this.formData.orders_area_product_detail_id
  517. );
  518. }
  519. });
  520. },
  521. onCancel: () => {
  522. console.log(this.$refs.selection);
  523. },
  524. });
  525. }
  526. },
  527. //项目辅料新增
  528. handleAddSup() {
  529. this.supTableData.push({ id: "" });
  530. },
  531. //项目辅料删除
  532. handleSupSet(row, index) {
  533. this.supTableData.splice(index, 1);
  534. },
  535. handlechange(val) {
  536. console.log("val :>> ", val);
  537. },
  538. initData(order_no, orders_area_product_detail_id) {
  539. this.axios({
  540. method: "get",
  541. url: "/api/order_area_explode",
  542. params: {
  543. order_no,
  544. oa_id: this.$route.query.oa_id,
  545. ...this.searchData,
  546. },
  547. }).then((res) => {
  548. this.formData = res.data;
  549. this.supTableData = res.data.ext;
  550. // this.formData.list.forEach((element) => {
  551. // element.product.forEach((el, index) => {
  552. // el.index = index + 1;
  553. // });
  554. // });
  555. });
  556. },
  557. // 1拆单 2详情 3变更
  558. handleSet(row, index, type) {
  559. this.$router.push({
  560. path: "/cms/BidSystem/ProductDeOrder/deorderdetail",
  561. query: {
  562. type,
  563. order_no: this.$route.query.order_no,
  564. oa_id: this.$route.query.oa_id,
  565. orders_area_product_detail_id: row.id,
  566. },
  567. });
  568. },
  569. postData() {
  570. this.axios({
  571. method: "post",
  572. url: "/api/order_area_add",
  573. data: {
  574. ...this.formData,
  575. },
  576. }).then((res) => {
  577. this.$Message.success(res.msg);
  578. });
  579. },
  580. goback() {
  581. this.$router.go(-1);
  582. },
  583. },
  584. // 监听属性 类似于data概念
  585. computed: {},
  586. // 监控data中的数据变化
  587. watch: {},
  588. beforeCreate() {}, // 生命周期 - 创建之前
  589. beforeMount() {}, // 生命周期 - 挂载之前
  590. beforeUpdate() {}, // 生命周期 - 更新之前
  591. updated() {}, // 生命周期 - 更新之后
  592. beforeDestroy() {}, // 生命周期 - 销毁之前
  593. destroyed() {}, // 生命周期 - 销毁完成
  594. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  595. };
  596. </script>
  597. <style lang="scss" scoped>
  598. .BidSystemProductDeOrderEdit {
  599. overflow: hidden;
  600. overflow-y: auto;
  601. .top_search {
  602. display: flex;
  603. justify-content: flex-start;
  604. align-items: center;
  605. flex-wrap: wrap;
  606. width: 100%;
  607. padding: 10px 0;
  608. font-size: 14px;
  609. div {
  610. width: 200px;
  611. padding: 5px;
  612. }
  613. }
  614. .addArea {
  615. .addAreaTable {
  616. padding: 20px 0;
  617. }
  618. position: relative;
  619. padding: 15px;
  620. margin-bottom: 30px;
  621. border-radius: 5px;
  622. box-shadow: 1px 1px 5px 1px #999;
  623. .addAreaBtn {
  624. position: absolute;
  625. right: 20px;
  626. top: 20px;
  627. }
  628. /deep/ .ivu-form-item {
  629. display: inline-block;
  630. width: 220px;
  631. }
  632. }
  633. }
  634. .supModalBtn {
  635. display: flex;
  636. justify-content: flex-end;
  637. margin-bottom: 10px;
  638. }
  639. </style>