index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div>
  3. <FullPage
  4. title="工艺组合"
  5. :list="list"
  6. @init="init"
  7. :loading="loading"
  8. @searchData="init"
  9. @changePage="changePage"
  10. @changeSize="changeSize"
  11. :tableColums="tableColums"
  12. :tableData="tableData"
  13. :pageIndex="pageIndex"
  14. :total="total"
  15. >
  16. <div slot="titleButton" style="display:flex;">
  17. <Upload
  18. v-if="persimissionData['批量导入'] || persimissionData.all"
  19. name="your_file"
  20. :show-upload-list="false"
  21. :headers="headers"
  22. :on-error="uploadError"
  23. :on-success="uploadSuccess"
  24. :action="$store.state.ip + '/api/process_route_index_import'"
  25. >
  26. <Button type="success" ghost icon="md-exit" style="margin-right:10px;"
  27. >批量导入</Button
  28. >
  29. </Upload>
  30. <Button
  31. v-if="persimissionData['批量导出'] || persimissionData.all"
  32. @click="exportData"
  33. type="warning"
  34. ghost
  35. icon="md-return-left"
  36. style="margin-right:10px;"
  37. >批量导出</Button
  38. >
  39. <Button
  40. v-if="persimissionData['新增工艺'] || persimissionData.all"
  41. @click="goPage(1)"
  42. type="primary"
  43. ghost
  44. icon="md-add"
  45. >新增工艺组合</Button
  46. >
  47. </div>
  48. <div slot="navButton">
  49. <Button @click="handleSortSet" type="primary">排序设置</Button>
  50. </div>
  51. <template slot="set" slot-scope="{ row }">
  52. <div class="table-set">
  53. <svg
  54. style="font-size:20px"
  55. color="#3764FF"
  56. @click="goPage(4, row)"
  57. class="icon icon-nav"
  58. aria-hidden="true"
  59. >
  60. <use xlink:href="#iconcopy-01"></use>
  61. </svg>
  62. <svg
  63. v-if="persimissionData['编辑'] || persimissionData.all"
  64. style="font-size:20px"
  65. color="#3764FF"
  66. @click="goPage(2, row)"
  67. class="icon icon-nav"
  68. aria-hidden="true"
  69. >
  70. <use xlink:href="#iconbianji"></use>
  71. </svg>
  72. <svg
  73. style="font-size:20px"
  74. color="green"
  75. @click="goPage(3, row)"
  76. class="icon icon-nav"
  77. aria-hidden="true"
  78. >
  79. <use xlink:href="#iconxiangqing"></use>
  80. </svg>
  81. <svg
  82. v-if="persimissionData['删除'] || persimissionData.all"
  83. @click="delItems(row)"
  84. class="icon icon-nav"
  85. style="font-size:20px"
  86. color="red"
  87. aria-hidden="true"
  88. >
  89. <use xlink:href="#iconshanchu"></use>
  90. </svg>
  91. </div>
  92. </template>
  93. </FullPage>
  94. <Modal v-model="showSortModal" title="排序设置" width="650">
  95. <div>
  96. <Form
  97. :label-width="80"
  98. inline
  99. v-for="(_item, _index) in sortList"
  100. :key="_index"
  101. >
  102. <FormItem :label="'关键字' + (_index + 1)">
  103. <Select filterable clearable transfer v-model="_item.value">
  104. <Option
  105. v-for="item of headerList"
  106. :key="item.key"
  107. :label="item.title"
  108. :disabled="
  109. item.title == '操作' ||
  110. item.title == '已收款' ||
  111. item.title == '未收款'
  112. "
  113. :value="item.key"
  114. ></Option>
  115. </Select>
  116. </FormItem>
  117. <FormItem label="排序方式">
  118. <Select
  119. style="width:150px"
  120. filterable
  121. clearable
  122. transfer
  123. v-model="_item.sort"
  124. >
  125. <Option label="升序" :value="1"></Option>
  126. <Option label="降序" :value="2"></Option>
  127. </Select>
  128. </FormItem>
  129. <FormItem :label-width="10">
  130. <Icon
  131. @click="
  132. handleSortListChange(sortList, 0, _index, {
  133. sort: null,
  134. level: sortList.length + 1,
  135. value: '',
  136. })
  137. "
  138. v-show="sortList.length < 2"
  139. style="'margin:0 10px"
  140. size="20"
  141. type="ios-add"
  142. />
  143. <Icon
  144. @click="handleSortListChange(sortList, 1, _index, null)"
  145. v-show="sortList.length > 1"
  146. style="'margin:0 10px"
  147. size="20"
  148. type="ios-remove"
  149. />
  150. </FormItem>
  151. </Form>
  152. </div>
  153. <div slot="footer">
  154. <Button
  155. @click="showSortModal = false"
  156. type="primary"
  157. style="margin-right: 10px"
  158. >取消</Button
  159. >
  160. <Button
  161. @click="handleConfirmSort"
  162. type="primary"
  163. style="margin-right: 10px"
  164. >确定</Button
  165. >
  166. </div>
  167. </Modal>
  168. </div>
  169. </template>
  170. <script>
  171. import { mapState } from "vuex";
  172. export default {
  173. data() {
  174. return {
  175. list: [
  176. {
  177. title: "工艺组合名称",
  178. name: "Input",
  179. value: "",
  180. serverName: "title",
  181. placeholder: "请输入工艺组合名称",
  182. },
  183. ],
  184. tableColums: [],
  185. tableData: [],
  186. pageIndex: 1,
  187. total: 0,
  188. pageSize: 10,
  189. proxyObj: {},
  190. loading: false,
  191. headers: { Authorization: localStorage.getItem("token") },
  192. showSortModal: false,
  193. sortList: [{ sort: null, level: 1, value: "" }],
  194. headerList: [
  195. { key: "part_title", title: "部件名称" },
  196. { key: "process_title", title: "工艺组合名称" },
  197. ],
  198. };
  199. },
  200. computed: {
  201. ...mapState(["persimissionData"]),
  202. },
  203. beforeRouteLeave(to, from, next) {
  204. if (to.path == "/cms/processroute/edit") {
  205. this.$route.meta.keepAlive = true;
  206. } else {
  207. this.$route.meta.keepAlive = false;
  208. }
  209. next();
  210. },
  211. beforeRouteEnter(to, from, next) {
  212. next((vm) => {
  213. vm.getData(vm.proxyObj);
  214. });
  215. },
  216. methods: {
  217. init(row) {
  218. this.pageIndex = 1;
  219. row.page_index = this.pageIndex;
  220. row.page_size = this.pageSize;
  221. this.proxyObj = row;
  222. this.getData(row);
  223. },
  224. getData(row) {
  225. this.loading = true;
  226. this.axios("/api/process_route_index", { params: row }).then((res) => {
  227. this.loading = false;
  228. res.data.top.map((v, i) => {
  229. if (v.key == "颜色") {
  230. v.hover = 1;
  231. }
  232. if (i == 0) {
  233. v.fixed = "left";
  234. v.width = "100";
  235. } else {
  236. if (i == res.data.top.length - 1) {
  237. v.fixed = "right";
  238. v.width = "150";
  239. } else {
  240. v.minWidth = 150;
  241. }
  242. }
  243. if (v.hover == 1) {
  244. v.render = function(h, params) {
  245. const { row } = params;
  246. return h(
  247. "Tooltip",
  248. {
  249. props: {
  250. content: row[v.key],
  251. placement: "right",
  252. maxWidth: "200",
  253. style: {
  254. zIndex: 10000,
  255. },
  256. },
  257. },
  258. [
  259. h(
  260. "div",
  261. {
  262. props: {},
  263. style: {
  264. width: "100px",
  265. overflow: "hidden",
  266. whiteSpace: "nowrap",
  267. textOverflow: "ellipsis",
  268. },
  269. },
  270. row[v.key]
  271. ),
  272. ]
  273. );
  274. };
  275. }
  276. });
  277. this.tableColums = res.data.top;
  278. this.tableData = res.data.detail;
  279. this.total = res.data.total;
  280. });
  281. },
  282. changePage(e) {
  283. this.pageIndex = e;
  284. this.proxyObj.page_index = this.pageIndex;
  285. this.getData(this.proxyObj);
  286. },
  287. changeSize(e) {
  288. this.pageSize = e;
  289. this.proxyObj.page_size = this.pageSize;
  290. this.getData(this.proxyObj);
  291. },
  292. goPage(n, row) {
  293. let id = row ? row.id : "";
  294. this.$router.push({
  295. path: "/cms/processroute/edit",
  296. query: {
  297. type: n,
  298. id: id,
  299. },
  300. });
  301. },
  302. handleSortSet() {
  303. this.showSortModal = true;
  304. },
  305. handleSortListChange(arr, type, index, obj) {
  306. if (obj) {
  307. arr.splice(index + 1, type, obj);
  308. } else {
  309. arr.splice(index, type);
  310. }
  311. },
  312. handleConfirmSort() {
  313. if (
  314. this.sortList.length > 1 ||
  315. (this.sortList.length == 1 && this.sortList[0].sort)
  316. ) {
  317. this.loading = true;
  318. this.axios("/api/order_list_new", {
  319. params: { ...this.proxyObj, sortList: this.sortList },
  320. }).then((res) => {
  321. if (res.code == 200) {
  322. this.loading = false;
  323. if (!res.data.data) {
  324. return this.$Message.error("列表数据返回格式不正确");
  325. }
  326. this.tableData = res.data.data;
  327. this.total = res.data.total;
  328. this.showSortModal = false;
  329. // this.tableModalTableData =
  330. // res.data.tableSet.tableSet.length < 1
  331. // ? this.tableModalTableData
  332. // : res.data.tableSet.tableSet;
  333. // this.formModalTableData =
  334. // res.data.tableSet.formSet.length < 1
  335. // ? this.formModalTableData
  336. // : res.data.tableSet.formSet;
  337. // this.sub_formModalTableData = JSON.parse(
  338. // JSON.stringify(this.formModalTableData)
  339. // );
  340. // this.sub_tableModalTableData = JSON.parse(
  341. // JSON.stringify(this.tableModalTableData)
  342. // );
  343. }
  344. });
  345. } else {
  346. this.showSortModal = false;
  347. }
  348. },
  349. delItems(row) {
  350. this.confirmDelete({
  351. content: "确认删除么?",
  352. then: () => {
  353. this.axios
  354. .post("/api/process_route_del", { id: row.id, state: 0 })
  355. .then((res) => {
  356. if (res.code == 200) {
  357. this.$Message.success(res.msg);
  358. this.getData(this.proxyObj);
  359. }
  360. });
  361. },
  362. });
  363. },
  364. async exportData() {
  365. const res = await this.axios("/api/process_route_index_export", {
  366. params: { ...this.proxyObj, page: 0 },
  367. });
  368. if (res.code == 200) {
  369. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`;
  370. location.href = url;
  371. }
  372. },
  373. uploadSuccess(res) {
  374. if (res.code == 200) {
  375. this.$Message.success(res.msg || "上传成功");
  376. } else {
  377. this.$Message.warning(res.msg || "上传失败");
  378. }
  379. this.getData(this.proxyObj);
  380. },
  381. uploadError(err) {
  382. this.$Message.error(err.msg || "上传失败");
  383. },
  384. },
  385. };
  386. </script>
  387. <style lang="scss" scoped>
  388. /deep/ .ivu-table-wrapper {
  389. overflow: visible;
  390. }
  391. </style>