edit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div>
  3. <Toptitle
  4. ref="toptitle"
  5. :title="this.$route.query.editType == 0 ? '编辑订单' : '查看订单详情'"
  6. >
  7. <Button
  8. @click="handleGoDeOrder"
  9. v-if="$route.query.type == 3"
  10. type="primary"
  11. ghost
  12. style="margin-right: 10px"
  13. >拆单</Button
  14. >
  15. <Button @click="back" type="primary" ghost style="margin-right: 10px"
  16. >返回</Button
  17. >
  18. <Button
  19. :disabled="$route.query.editType == 1 ? true : false"
  20. type="primary"
  21. ghost
  22. style="margin-right: 10px"
  23. @click="postData"
  24. >保存</Button
  25. >
  26. <!-- <Button
  27. :disabled="$route.query.editType == 1 ? true : false"
  28. type="primary"
  29. ghost
  30. style="margin-right: 10px"
  31. @click="batchConfirm"
  32. >批量确认</Button
  33. > -->
  34. <Button
  35. :disabled="$route.query.editType != 1 ? true : false"
  36. type="primary"
  37. ghost
  38. @click="openModal"
  39. >批量下生产</Button
  40. >
  41. </Toptitle>
  42. <Topsearch
  43. ref="topsearch"
  44. :list="list"
  45. @init="init"
  46. @searchData="init"
  47. ></Topsearch>
  48. <div ref="log" class="log-list">
  49. <div class="log-item" v-for="(item, index) of logList" :key="index">
  50. <span>{{ item.key }}:</span>
  51. <span>{{ item.value }}</span>
  52. </div>
  53. </div>
  54. <div>
  55. <Table
  56. ref="table"
  57. @on-selection-change="selectTable"
  58. :max-height="tableHeight"
  59. :width="tableWidth"
  60. class="overflow-table"
  61. border
  62. stripe
  63. :columns="tableColums"
  64. :data="tableData"
  65. >
  66. <div
  67. slot-scope="{ index }"
  68. v-for="(item, _key) in tableTop"
  69. :key="_key"
  70. :slot="item.slot"
  71. >
  72. <Input
  73. :disabled="$route.query.editType == 1 ? true : false"
  74. v-model="tableData[index][item.key]"
  75. :placeholder="'请输入' + item.title"
  76. />
  77. </div>
  78. <template slot-scope="{ row }" slot="up-load">
  79. <div>
  80. <img
  81. @click="getImg(row)"
  82. style="
  83. max-width: 50px;
  84. max-height: 50px;
  85. position: relative;
  86. top: 3px;
  87. "
  88. :src="$store.state.ip + row.url"
  89. />
  90. </div>
  91. </template>
  92. </Table>
  93. </div>
  94. <Footer
  95. @change="changePage"
  96. @changeSize="changeSize"
  97. :total="total"
  98. :pageIndex="pageIndex"
  99. ></Footer>
  100. </div>
  101. </template>
  102. <script>
  103. export default {
  104. data() {
  105. return {
  106. list: [
  107. {
  108. title: "楼幢",
  109. name: "Select",
  110. multiple: true,
  111. filterable: true,
  112. serverName: "house",
  113. placeholder: "请选择",
  114. value: "",
  115. option: [],
  116. },
  117. {
  118. title: "单元",
  119. name: "Select",
  120. multiple: true,
  121. filterable: true,
  122. serverName: "unit",
  123. placeholder: "请选择",
  124. value: "",
  125. option: [],
  126. },
  127. {
  128. title: "楼层",
  129. name: "Select",
  130. multiple: true,
  131. filterable: true,
  132. serverName: "layer",
  133. placeholder: "请选择",
  134. value: "",
  135. option: [],
  136. },
  137. {
  138. title: "房号",
  139. name: "Select",
  140. multiple: true,
  141. filterable: true,
  142. serverName: "number_detail",
  143. placeholder: "请选择",
  144. value: "",
  145. option: [],
  146. },
  147. {
  148. title: "产品名称",
  149. name: "Select",
  150. multiple: true,
  151. filterable: true,
  152. serverName: "product",
  153. placeholder: "请选择",
  154. value: "",
  155. option: [],
  156. },
  157. {
  158. title: "图号",
  159. name: "Select",
  160. multiple: true,
  161. filterable: true,
  162. serverName: "url_number",
  163. placeholder: "请选择",
  164. value: "",
  165. option: [],
  166. },
  167. // {
  168. // title: "测量状态",
  169. // name: "Select",
  170. // serverName: "measurement_state",
  171. // placeholder: "请选择",
  172. // value: "",
  173. // option: [
  174. // { label: "全部", value: 99 },
  175. // { label: "测量中", value: 2 },
  176. // { label: "测量完成", value: 3 },
  177. // ],
  178. // },
  179. ],
  180. type: 1,
  181. logList: [{ title: "系统单号", value: "10998765" }],
  182. tableColums: [
  183. { type: "selection", width: 100, align: "center" },
  184. {
  185. title: "房间号",
  186. align: "center",
  187. key: "number_detail",
  188. minWidth: 100,
  189. render: (h, params) => {
  190. const { row } = params;
  191. return h(
  192. "span",
  193. `${row.house}-${row.unit}-${row.layer}-${row.number_detail}`
  194. );
  195. },
  196. },
  197. {
  198. title: "产品名称",
  199. align: "center",
  200. key: "product_title",
  201. minWidth: 200,
  202. },
  203. { title: "产品型号", align: "center", key: "model", minWidth: 150 },
  204. { title: "单位", align: "center", key: "unit", minWidth: 130 },
  205. { title: "图号", align: "center", minWidth: 130, key: "url_number" },
  206. { title: "图纸", align: "center", slot: "up-load", minWidth: 130 },
  207. { title: "位置", align: "center", minWidth: 200, key: "position" },
  208. // {
  209. // title: "状态",
  210. // align: "center",
  211. // minWidth: 100,
  212. // render: (h, params) =>
  213. // h("span", {}, params.row.is_measure == 1 ? "已确认" : "未确认"),
  214. // },
  215. // {
  216. // title: "测量状态",
  217. // align: "center",
  218. // key: "measurement_state",
  219. // minWidth: 100,
  220. // render: (h, params) =>
  221. // h(
  222. // "span",
  223. // {},
  224. // params.row.is_measure == 1
  225. // ? "测量完成"
  226. // : params.row.measurement_state >= 3
  227. // ? "测量完成"
  228. // : params.row.measurement_state == 1
  229. // ? "已下测量"
  230. // : params.row.measurement_state == 2
  231. // ? "测量中"
  232. // : "未下测量"
  233. // ),
  234. // },
  235. // {
  236. // title: "预估产品工期",
  237. // align: "center",
  238. // minWidth: 200,
  239. // key: "predict_working",
  240. // render: (h, params) =>
  241. // h("span", `${(params.row.predict_working / 8).toFixed(1)}天`),
  242. // },
  243. {
  244. title: "测量数据",
  245. align: "center",
  246. width: "200",
  247. key: "measurement",
  248. },
  249. ],
  250. tableData: [],
  251. pageIndex: 1,
  252. pageSize: 10,
  253. total: 100,
  254. headers: { Authorization: localStorage.getItem("token") },
  255. currentIndex: 0,
  256. planInfo: {
  257. order_product_id: "",
  258. },
  259. tableWidth: null,
  260. tableTop: [],
  261. select: [],
  262. bannerImages: [],
  263. proxyObj: {},
  264. tableHeight: null,
  265. };
  266. },
  267. created() {
  268. this.tableWidth = window.innerWidth - 320;
  269. this.type = this.$route.query.type;
  270. this.getOptions();
  271. },
  272. mounted() {
  273. this.tableHeight =
  274. window.innerHeight -
  275. this.$refs.table.$el.offsetTop -
  276. this.$refs.toptitle.$el.offsetHeight -
  277. this.$refs.topsearch.$el.offsetHeight -
  278. 200;
  279. window.addEventListener("resize", (e) => {
  280. this.tableWidth = e.target.innerWidth - 300;
  281. this.$forceUpdate();
  282. });
  283. },
  284. methods: {
  285. handleGoDeOrder() {
  286. this.$router.push({
  287. path: "/cms/BidSystem/ProductDeOrder/detail",
  288. query: {
  289. type: this.$route.query.type,
  290. order_no: this.$route.query.order_no,
  291. oa_id:this.$route.query.oa_id
  292. },
  293. });
  294. },
  295. init(row) {
  296. this.pageIndex = 1;
  297. row.page_index = this.pageIndex;
  298. row.page_size = this.pageSize;
  299. if (this.func.isType(row.house) == "Array") {
  300. row.house = row.house.join(",");
  301. }
  302. if (this.func.isType(row.unit) == "Array") {
  303. row.unit = row.unit.join(",");
  304. }
  305. if (this.func.isType(row.layer) == "Array") {
  306. row.layer = row.layer.join(",");
  307. }
  308. if (this.func.isType(row.number_detail) == "Array") {
  309. row.number_detail = row.number_detail.join(",");
  310. }
  311. if (this.func.isType(row.product) == "Array") {
  312. row.product = row.product.join(",");
  313. }
  314. if (this.func.isType(row.url_number) == "Array") {
  315. row.url_number = row.url_number.join(",");
  316. }
  317. Object.assign(row, this.$route.query);
  318. Object.assign(this.proxyObj, row);
  319. this.getData(row);
  320. },
  321. getOptions() {
  322. this.axios("/api/order_detail_word", {
  323. params: { order_no: this.$route.query.order_no },
  324. }).then((res) => {
  325. res.data.house.map((v) => {
  326. v.value = v.house;
  327. v.label = v.house;
  328. });
  329. res.data.unit.map((v) => {
  330. v.value = v.unit;
  331. v.label = v.unit;
  332. });
  333. res.data.layer.map((v) => {
  334. v.value = v.layer;
  335. v.label = v.layer;
  336. });
  337. res.data.number_detail.map((v) => {
  338. v.value = v.number_detail;
  339. v.label = v.number_detail;
  340. });
  341. res.data.product.map((v) => {
  342. v.value = v.product;
  343. v.label = v.product;
  344. });
  345. res.data.url_number.map((v) => {
  346. v.value = v.url_number;
  347. v.label = v.url_number;
  348. });
  349. this.list[0].option = res.data.house;
  350. this.list[1].option = res.data.unit;
  351. this.list[2].option = res.data.layer;
  352. this.list[3].option = res.data.number_detail;
  353. this.list[4].option = res.data.product;
  354. this.list[5].option = res.data.url_number;
  355. });
  356. },
  357. back() {
  358. this.$router.go(-1);
  359. },
  360. selectTable(e) {
  361. this.select = e;
  362. },
  363. postData() {
  364. let result = [];
  365. this.tableData.map((v, i) => {
  366. let obj = {};
  367. obj.order_product_id = v.order_product_id;
  368. obj.url = v.url || "";
  369. obj.url_number = v.url_number || "";
  370. obj.detail = [];
  371. this.tableTop.map((k) => {
  372. let o = {};
  373. let key = k.key;
  374. for (let m in this.tableData[i]) {
  375. if (m == key) {
  376. o.key = key;
  377. o.value = this.tableData[i][key];
  378. o.title = k.title;
  379. obj.detail.push(o);
  380. }
  381. }
  382. });
  383. result.push(obj);
  384. });
  385. let postInfo = JSON.stringify(result);
  386. this.axios
  387. .post("/api/orders_save_measure", { data: postInfo })
  388. .then((res) => {
  389. if (res.code == 200) {
  390. this.$Message.success(res.msg);
  391. this.getData(this.proxyObj);
  392. }
  393. });
  394. },
  395. getData(row) {
  396. this.axios("/api/orders_product_list", { params: row }).then((res) => {
  397. this.tableData = res.data.list;
  398. this.logList = res.data.detail;
  399. this.tableTop = res.data.top;
  400. this.total = res.data.total;
  401. // res.data.top.map((v) => {
  402. // v.width = 200;
  403. // v.slot = v.key;
  404. // const n = this.tableColums.filter((x) => x.key == v.key);
  405. // if (n.length < 1) {
  406. // this.tableColums.splice(5, 0, v);
  407. // }
  408. // });
  409. });
  410. },
  411. successUpload(event) {
  412. let url = event.data.url;
  413. this.tableData[this.currentIndex].url = url;
  414. },
  415. mapRow(n) {
  416. this.currentIndex = n;
  417. },
  418. changePage(e) {},
  419. openModal() {
  420. const result = this.select.map((rows) => rows.order_product_id);
  421. if (!result || result.length < 1) {
  422. return this.$Message.error("请至少选择一项");
  423. }
  424. this.planInfo.order_product_id = result.join(",");
  425. this.downProduction({
  426. title: "下生产",
  427. type: 2,
  428. params: this.planInfo,
  429. then: (e) => {
  430. this.getData(this.proxyObj);
  431. },
  432. cancel: (e) => {},
  433. });
  434. },
  435. batchConfirm() {
  436. if (this.select.length < 1) {
  437. return this.$Message.warning("请选择");
  438. }
  439. console.log(this.tableTop);
  440. let result = [];
  441. this.select.map((rows) => {
  442. const obj = {};
  443. this.tableTop.forEach((item) => {
  444. const { key } = item;
  445. for (let i in rows) {
  446. if (key == i) {
  447. obj[key] = rows[key];
  448. }
  449. }
  450. });
  451. result.push({ id: rows.id, detail: obj });
  452. });
  453. this.axios.post("/api/batch_confirm", { result: result }).then((res) => {
  454. if (res.code == 200) {
  455. this.$Message.success(res.msg);
  456. this.getData(this.proxyObj);
  457. }
  458. });
  459. },
  460. getImg(row) {
  461. if (row.imgs && row.imgs.length > 0) {
  462. this.$previewImg({
  463. list: row.imgs,
  464. baseUrl: this.$store.state.ip,
  465. baseImgField: "img_url",
  466. baseTitleField: "",
  467. });
  468. } else {
  469. this.axios("/api/orders_img", {
  470. params: { id: row.product_id, type: 1 },
  471. }).then((res) => {
  472. if (res.code == 200) {
  473. row.imgs = res.data;
  474. this.$previewImg({
  475. list: row.imgs,
  476. baseUrl: this.$store.state.ip,
  477. baseImgField: "img_url",
  478. baseTitleField: "",
  479. });
  480. }
  481. });
  482. }
  483. },
  484. changeSize(e) {
  485. this.pageSize = e;
  486. this.proxyObj.page_size = this.pageSize;
  487. this.getData(this.proxyObj);
  488. },
  489. },
  490. };
  491. </script>
  492. <style lang="scss" scoped>
  493. .log-list {
  494. display: flex;
  495. flex-wrap: wrap;
  496. padding: 10px 0;
  497. }
  498. /deep/ .ivu-table-wrapper {
  499. overflow: visible;
  500. color: red;
  501. } //穿透iview
  502. // .page-edit{overflow: hidden;overflow-y: auto;position:relative;top:20px;height:80%;}
  503. </style>