index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <!-- 采购订单修订—— 查看 -->
  2. <script>
  3. import {
  4. initColumns,
  5. initDicts,
  6. initRules,
  7. initParams,
  8. } from "@/utils/init/index.js";
  9. // import { Columns, TabColumns } from "../add/column";
  10. import orderApi from "@/api/business/purchase/purchase-order";
  11. import { PRINT } from "@/api/business/purchase/task";
  12. import judgeColumns from "../add/column";
  13. import VirtualScroll from "el-table-virtual-scroll";
  14. import { VirtualColumn } from "el-table-virtual-scroll";
  15. const { Columns, TabColumns } = judgeColumns();
  16. const NewColumns = initColumns(Columns);
  17. const NewTabColumns = TabColumns.map((element) => ({
  18. ...element,
  19. tableColumns: initColumns(element.tableColumns).map((item, index) => ({
  20. ...item,
  21. hidden: true,
  22. })),
  23. }));
  24. //
  25. const SelectColumns = NewColumns.filter(
  26. (column) => column.inputType === "Select"
  27. );
  28. NewTabColumns.forEach((column) => {
  29. SelectColumns.push(
  30. ...column.tableColumns.filter((cColumn) => cColumn.inputType === "Select")
  31. );
  32. });
  33. export default {
  34. name: "SeePurchaseOrderDrawer",
  35. dicts: initDicts(SelectColumns),
  36. components: {
  37. "virtual-scroll": VirtualScroll,
  38. VirtualColumn,
  39. FileUploadCenter: () => import("../components/FileUploadCenter/index.vue"),
  40. FilePrint: () => import("../print/index.vue"),
  41. ButtonHide: () => import("../components/hide/index.vue"),
  42. },
  43. data() {
  44. return {
  45. visible: false,
  46. loading: false,
  47. columns: NewColumns,
  48. printData: {},
  49. rules: initRules(NewColumns),
  50. params: {
  51. ...initParams(NewColumns),
  52. puOrderItemList: [],
  53. // puOrderExecuteList: [],
  54. },
  55. tabColumns: NewTabColumns,
  56. tabName: "puOrderItemList",
  57. tableData: [], //虚拟滚动加载显示的数据
  58. size: "mini",
  59. };
  60. },
  61. computed: {
  62. tabHeight: {
  63. get() {
  64. let length = this.params["puOrderItemList"].filter(
  65. (item) => item.delFlag === "0"
  66. ).length;
  67. return `${length ? (length > 8 ? 500 : length * 36 + 120) : 120}px`;
  68. },
  69. set() {},
  70. },
  71. innerColumns: {
  72. get() {
  73. let { tabName, tabColumns } = this;
  74. let obj = tabColumns.find(({ key }) => key === tabName).tableColumns;
  75. return obj;
  76. },
  77. set(value) {
  78. let { tabName, tabColumns } = this;
  79. this.tabColumns = tabColumns.map((item) => {
  80. if (item.key === tabName) {
  81. item.tableColumns = value;
  82. }
  83. return { ...item };
  84. });
  85. this.$nextTick(() => {
  86. this.$refs.puOrderItemList &&
  87. this.$refs.puOrderItemList[0].doLayout();
  88. });
  89. },
  90. },
  91. },
  92. watch: {},
  93. methods: {
  94. setVisible(prop) {
  95. this.visible = prop;
  96. if (!this.visible) {
  97. this.$refs["orderSeeForm"].clearValidate();
  98. }
  99. },
  100. //查询详情
  101. async fetchItem(prop) {
  102. try {
  103. this.loading = true;
  104. const { code, msg, data } = await orderApi.details(prop);
  105. if (code === 200) {
  106. this.params = data;
  107. }
  108. } catch (err) {
  109. //
  110. } finally {
  111. this.loading = false;
  112. }
  113. try {
  114. this.loading = true;
  115. const { data, code } = await PRINT({ id: this.params.id || 628 });
  116. if (code === 200) {
  117. this.printData = data;
  118. this.loading = false;
  119. }
  120. } catch (err) {
  121. alert(err);
  122. } finally {
  123. }
  124. },
  125. // 取 消
  126. handleCancel() {
  127. // this.params = initParams(Columns);
  128. this.params = {
  129. ...initParams(this.columns),
  130. puOrderItemList: [],
  131. // puOrderExecuteList: [],
  132. };
  133. this.setVisible(false);
  134. },
  135. handleRefresh() {
  136. let { id } = this.params;
  137. this.fetchItem(id);
  138. },
  139. // 发送NC
  140. async handleSendNC() {
  141. try {
  142. let { code } = await orderApi.toNc({ puOrderId: this.params.id });
  143. if (code == 200) {
  144. this.handleRefresh();
  145. }
  146. } catch (error) {
  147. } finally {
  148. }
  149. },
  150. // 判断是否能发送NC
  151. judgeIsToNC() {
  152. let { source, status, deliveryStatus } = this.params;
  153. // 自制 & 状态为:自由态、驳回
  154. // if(source === '3' &&(status === '0' || status === '3')){
  155. if (status === "2") {
  156. // 发送NC之后展示 SUCCESS("0","成功"),SEND_IN("1","发送中"),FAILURE("2","失败");
  157. // 未发送 发送过但未成功
  158. if (!deliveryStatus || (deliveryStatus && deliveryStatus !== "0")) {
  159. return true;
  160. }
  161. return false;
  162. }
  163. return false;
  164. },
  165. beforeOpen() {},
  166. getSummaries({ columns, data }) {
  167. const means = []; // 合计
  168. let { tabColumns, tabName } = this;
  169. columns.forEach((column, columnIndex) => {
  170. if (columnIndex === 0) {
  171. means.push("合计");
  172. } else {
  173. const values = data.map((item) => Number(item[column.property]));
  174. let sumColumn = tabColumns
  175. .find((tab) => tab.key === tabName)
  176. .tableColumns.filter((item) => item.hidden)
  177. .filter(
  178. ({ key, isSummary }) => isSummary && key === column.property
  179. );
  180. // 合计
  181. // if (!values.every(value => isNaN(value))) {
  182. if (sumColumn.length) {
  183. means[columnIndex] = values.reduce((prev, curr) => {
  184. const value = Number(curr);
  185. if (!isNaN(value)) {
  186. return prev + curr;
  187. } else {
  188. return prev;
  189. }
  190. }, 0);
  191. means[columnIndex] = means[columnIndex].toFixed(2);
  192. } else {
  193. means[columnIndex] = "";
  194. }
  195. }
  196. });
  197. // sums[index] = sums[index] && sums[index].toFixed(2); // 保留2位小数,解决小数合计列
  198. return [means];
  199. },
  200. onHide(prop) {
  201. this.innerColumns = prop;
  202. },
  203. },
  204. created() {},
  205. mounted() {},
  206. destroyed() {},
  207. };
  208. </script>
  209. <template>
  210. <el-drawer
  211. direction="btt"
  212. size="100%"
  213. :with-header="false"
  214. :visible.sync="visible"
  215. @open="beforeOpen"
  216. @close="$emit('close')"
  217. v-loading="loading"
  218. >
  219. <el-form
  220. :size="size"
  221. label-position="right"
  222. label-width="140px"
  223. :model="params"
  224. :rules="rules"
  225. ref="orderSeeForm"
  226. class="orderSeeForm"
  227. >
  228. <el-card
  229. :body-style="{
  230. padding: '20px',
  231. display: 'flex',
  232. 'flex-wrap': 'wrap',
  233. }"
  234. style="margin: 10px"
  235. >
  236. <div
  237. slot="header"
  238. style="
  239. display: flex;
  240. justify-content: space-between;
  241. align-items: center;
  242. "
  243. >
  244. <h3>查看</h3>
  245. <div style="text-align: right">
  246. <FilePrint v-model="printData"></FilePrint>
  247. <el-button :size="size" @click="handleRefresh">刷新</el-button>
  248. <template v-if="judgeIsToNC()">
  249. <el-tooltip
  250. class="box-item"
  251. effect="dark"
  252. :key="params.deliveryStatus"
  253. :content="params.deliveryMsg"
  254. placement="bottom-end"
  255. >
  256. <el-button
  257. :key="params.deliveryStatus"
  258. :disabled="params.deliveryStatus === '1'"
  259. :size="size"
  260. type="primary"
  261. @click="handleSendNC"
  262. >{{
  263. params.deliveryStatus === "1"
  264. ? "发送中"
  265. : params.deliveryStatus === "2"
  266. ? "重新发送NC"
  267. : "发送NC"
  268. }}</el-button
  269. >
  270. </el-tooltip>
  271. </template>
  272. <el-button :size="size" @click="handleCancel">取 消</el-button>
  273. </div>
  274. </div>
  275. <el-row style="display: flex; flex-wrap: wrap">
  276. <el-col
  277. v-for="(column, index) in columns"
  278. :key="index"
  279. :span="column.span || 6"
  280. >
  281. <el-form-item :prop="column.key" :label="column.title">
  282. <el-input
  283. v-if="column.inputType === 'Input'"
  284. v-model="params[column.key]"
  285. :placeholder="column.placeholder"
  286. :clearable="column.clearable"
  287. readonly
  288. style="width: 100%"
  289. ></el-input>
  290. <dr-popover-select
  291. v-if="column.inputType === 'PopoverSelect'"
  292. v-model="params[column.key]"
  293. disabled
  294. :value-key="column.valueKey"
  295. :source.sync="params"
  296. :title="column.title"
  297. :type="column.referName"
  298. :multiple="column.multiple"
  299. :placeholder="column.placeholder"
  300. :data-mapping="column.dataMapping"
  301. :query-params="column.queryParams"
  302. ></dr-popover-select>
  303. <el-input
  304. v-if="column.inputType === 'Textarea'"
  305. v-model="params[column.key]"
  306. type="textarea"
  307. :rows="column.rows"
  308. :placeholder="column.placeholder"
  309. :clearable="column.clearable"
  310. readonly
  311. :maxlength="column.maxlength"
  312. show-word-limit
  313. style="width: 100%"
  314. ></el-input>
  315. <el-input-number
  316. v-if="column.inputType === 'InputNumber'"
  317. v-model="params[column.key]"
  318. :controls-position="column.controlsPosition"
  319. :placeholder="column.placeholder"
  320. :clearable="column.clearable"
  321. :precision="column.precision"
  322. disabled
  323. style="width: 100%"
  324. ></el-input-number>
  325. <el-select
  326. v-if="column.inputType === 'Select'"
  327. v-model="params[column.key]"
  328. disabled
  329. :size="size"
  330. :clearable="column.clearable"
  331. :placeholder="column.placeholder"
  332. style="width: 100%"
  333. >
  334. <el-option
  335. v-for="item in dict.type[column.referName]"
  336. :key="item.value"
  337. :label="item.label"
  338. :value="item.value"
  339. >
  340. </el-option>
  341. </el-select>
  342. <el-select
  343. v-if="column.inputType === 'TagSelect'"
  344. v-model="params[column.key]"
  345. multiple
  346. clearable
  347. collapse-tags
  348. :placeholder="column.placeholder"
  349. :clearable="column.clearable"
  350. disabled
  351. style="width: 100%"
  352. >
  353. <template #prefix>
  354. <el-icon
  355. class="el-icon-view"
  356. style="cursor: pointer"
  357. @click.stop="$message.info(234)"
  358. >
  359. </el-icon>
  360. </template>
  361. <el-option
  362. v-for="item in options"
  363. :key="item.value"
  364. :label="item.label"
  365. :value="item.value"
  366. >
  367. </el-option>
  368. </el-select>
  369. <el-date-picker
  370. v-if="column.inputType === 'DatePicker'"
  371. v-model="params[column.key]"
  372. :type="column.type"
  373. :placeholder="column.placeholder"
  374. :clearable="column.clearable"
  375. readonly
  376. :picker-options="column.pickerOptions"
  377. style="width: 100%"
  378. ></el-date-picker>
  379. <el-checkbox
  380. v-if="column.inputType === 'Checkbox'"
  381. v-model="params[column.key]"
  382. disabled
  383. true-label="Y"
  384. false-label="N"
  385. ></el-checkbox>
  386. <file-upload-center
  387. v-if="column.inputType === 'Upload'"
  388. v-model="params[column.key]"
  389. :file-type="column.fileType"
  390. :disabled="true"
  391. ></file-upload-center>
  392. </el-form-item>
  393. </el-col>
  394. </el-row>
  395. </el-card>
  396. <el-card
  397. :body-style="{
  398. padding: '20px',
  399. display: 'flex',
  400. 'flex-wrap': 'wrap',
  401. position: 'relative',
  402. }"
  403. style="margin: 10px"
  404. >
  405. <el-tabs v-model="tabName" style="width: 100%">
  406. <el-tab-pane
  407. v-for="(column, index) in tabColumns"
  408. :key="index"
  409. :label="column.title"
  410. :name="column.key"
  411. >
  412. <ux-grid
  413. border
  414. use-virtual
  415. keep-source
  416. show-summary
  417. show-overflow
  418. beautify-table
  419. :size="size"
  420. :ref="column.key"
  421. :height="tabHeight"
  422. style="width: 100%"
  423. :data="params[column.key].filter((item) => item.delFlag === '0')"
  424. :summary-method="getSummaries"
  425. :header-row-style="{
  426. color: '#515a6e',
  427. }"
  428. >
  429. <ux-table-column
  430. title="序号"
  431. type="index"
  432. width="60"
  433. ></ux-table-column>
  434. <ux-table-column
  435. v-for="(cColumn, cIndex) in column.tableColumns.filter(
  436. (item) => item.hidden
  437. )"
  438. :key="cColumn.key + cColumn.hidden"
  439. :field="cColumn.key"
  440. :title="cColumn.title"
  441. :width="cColumn.width || 80"
  442. resizable
  443. >
  444. <template slot="header" slot-scope="scope">
  445. <span v-if="cColumn.require" style="color: #ff4949">*</span>
  446. <span>
  447. {{ cColumn.title }}
  448. </span>
  449. </template>
  450. <template slot-scope="scope">
  451. <el-form-item label-width="0">
  452. <span v-if="!cColumn.inputType">
  453. {{ scope.row[cColumn.key] }}
  454. </span>
  455. <el-input
  456. v-if="cColumn.inputType === 'Input'"
  457. v-model="scope.row[cColumn.key]"
  458. :placeholder="cColumn.placeholder"
  459. :clearable="cColumn.clearable"
  460. readonly
  461. :size="size"
  462. style="width: 100%"
  463. ></el-input>
  464. <!-- -->
  465. <dr-popover-select
  466. v-if="cColumn.inputType === 'PopoverSelect'"
  467. v-model="scope.row[cColumn.key]"
  468. :source.sync="scope.row"
  469. :title="cColumn.title"
  470. :value-key="cColumn.valueKey"
  471. disabled
  472. :type="cColumn.referName"
  473. :multiple="cColumn.multiple"
  474. :placeholder="cColumn.placeholder"
  475. :data-mapping="cColumn.dataMapping"
  476. :query-params="cColumn.queryParams"
  477. :size="size"
  478. ></dr-popover-select>
  479. <el-input-number
  480. v-if="cColumn.inputType === 'InputNumber'"
  481. v-model="scope.row[cColumn.key]"
  482. :precision="cColumn.precision"
  483. :controls-position="cColumn.controlsPosition"
  484. :placeholder="cColumn.placeholder"
  485. :clearable="cColumn.clearable"
  486. disabled
  487. :size="size"
  488. style="width: 100%"
  489. ></el-input-number>
  490. <el-select
  491. v-if="cColumn.inputType === 'Select'"
  492. v-model="scope.row[cColumn.key]"
  493. disabled
  494. :size="size"
  495. :clearable="cColumn.clearable"
  496. :placeholder="cColumn.placeholder"
  497. style="width: 100%"
  498. >
  499. <el-option
  500. v-for="item in dict.type[cColumn.referName]"
  501. :key="item.value"
  502. :label="item.label"
  503. :value="item.value"
  504. ></el-option>
  505. </el-select>
  506. <el-checkbox
  507. v-if="cColumn.inputType === 'Checkbox'"
  508. v-model="scope.row[cColumn.key]"
  509. disabled
  510. true-label="Y"
  511. false-label="N"
  512. ></el-checkbox>
  513. </el-form-item>
  514. <el-date-picker
  515. v-if="cColumn.inputType === 'DatePicker'"
  516. v-model="scope.row[cColumn.key]"
  517. :size="size"
  518. :type="cColumn.type"
  519. :placeholder="cColumn.placeholder"
  520. :clearable="cColumn.clearable"
  521. :disabled="cColumn.disabled"
  522. :picker-options="cColumn.pickerOptions"
  523. style="width: 100%"
  524. ></el-date-picker>
  525. </template>
  526. </ux-table-column>
  527. </ux-grid>
  528. </el-tab-pane>
  529. </el-tabs>
  530. <el-row style="margin-top: 10px">
  531. <el-col>
  532. <button-hide v-model="innerColumns" @change="onHide"></button-hide>
  533. </el-col>
  534. </el-row>
  535. </el-card>
  536. </el-form>
  537. </el-drawer>
  538. </template>
  539. <style scoped>
  540. .orderSeeForm >>> .el-form-item {
  541. margin-bottom: 5px;
  542. }
  543. ::v-deep .singleTable .el-form-item {
  544. margin-bottom: 0px;
  545. }
  546. ::v-deep.uxbeautifyTableClass
  547. .elx-header--column
  548. .elx-resizable.is--line:before {
  549. height: 100%;
  550. background-color: #dfe6ec;
  551. }
  552. </style>