list.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div>
  3. <FullPage
  4. title="客户产品价格表"
  5. :list="set_list"
  6. @init="init"
  7. :loading="loading"
  8. @searchData="searchData"
  9. @changePage="changePage"
  10. @changeSize="changeSize"
  11. :tableColums="tableColums"
  12. :tableData="tableData"
  13. :page_index="page_index"
  14. :total="total"
  15. >
  16. <div slot="titleButton" style="display:flex;">
  17. <Upload
  18. name="your_file"
  19. :show-upload-list="false"
  20. :headers="headers"
  21. :on-error="uploadError"
  22. :on-success="uploadSuccess"
  23. :action="$store.state.ip + '/api/measure_orders_import'"
  24. >
  25. <Button type="success" ghost icon="md-exit" style="margin-right:10px;"
  26. >导入</Button
  27. >
  28. </Upload>
  29. <Button
  30. @click="handleSet({}, -1, 1)"
  31. type="primary"
  32. style="margin-right:10px;"
  33. >新增</Button
  34. >
  35. </div>
  36. <template slot="set" slot-scope="{ row, index }">
  37. <div class="table-set">
  38. <!-- <a style="margin:0 5px"
  39. @click="handleSet(row,index,5)">审核</a> -->
  40. <a style="margin:0 5px" @click="handleSet(row, index, 2)">编辑</a>
  41. <a style="margin:0 5px" @click="handleSet(row, index, 3)">查看</a>
  42. <!-- <a style="margin:0 5px"
  43. @click="handleSet(row,index,6)">变更</a>
  44. <a style="margin:0 5px"
  45. @click="handleSet(row,index,7)">变更记录</a> -->
  46. <a style="margin:0 5px" @click="handleSet(row, index, 4)">删除</a>
  47. </div>
  48. </template>
  49. </FullPage>
  50. </div>
  51. </template>
  52. <script>
  53. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  54. // 例如:import 《组件名称》 from '《组件路径》';
  55. export default {
  56. name: "AdditionalProjectIndex",
  57. components: {},
  58. props: {},
  59. // import引入的组件需要注入到对象中才能使用
  60. data() {
  61. // 这里存放数据
  62. return {
  63. loading: false,
  64. tableData: [],
  65. page_index: 1,
  66. total: 0,
  67. page_size: 10,
  68. proxyObj: {},
  69. tableColums: [
  70. {
  71. title: "客户分类编码",
  72. key: "type_code",
  73. align: "center",
  74. minWidth: 140,
  75. },
  76. {
  77. title: "客户分类名称",
  78. key: "type_title",
  79. align: "center",
  80. minWidth: 140,
  81. },
  82. {
  83. title: "客户编码",
  84. key: "code",
  85. align: "center",
  86. tooltip: true,
  87. minWidth: 140,
  88. },
  89. {
  90. title: "客户名称",
  91. key: "title",
  92. align: "center",
  93. tooltip: true,
  94. minWidth: 140,
  95. },
  96. // {
  97. // title: '审核人', key: 'service_id', align: 'center', tooltip: true, minWidth: 140,
  98. // render: (h, params) => {
  99. // const { row } = params
  100. // let text
  101. // this.userList.forEach(element => {
  102. // (element.id == row.service_id) && (text = element.nickname)
  103. // });
  104. // return h('span', {}, text)
  105. // }
  106. // },
  107. // {
  108. // title: '审核状态', key: 'state', align: 'center', minWidth: 140,
  109. // render: (h, params) => {
  110. // const { row } = params
  111. // let text = row.state == 1 ? '已审核' : row.state == 2 ? '拒绝' : '未审核'
  112. // return h('span', {}, text)
  113. // }
  114. // },
  115. { title: "操作", key: "", align: "center", slot: "set", width: 300 },
  116. ],
  117. tableData: [],
  118. type: null,
  119. userList: [],
  120. overStandardList: [],
  121. headers: { Authorization: localStorage.getItem("token") },
  122. };
  123. },
  124. // 生命周期 - 创建完成(可以访问当前this实例)
  125. created() {
  126. // 获取用户列表
  127. this.axios({ method: "get", url: "/api/user" })
  128. .then((res) => {
  129. this.userList = res.data.data;
  130. })
  131. // 获取超标方案
  132. this.axios({ method: "get", url: "/api/overdraft_list" })
  133. .then((res) => {
  134. this.overStandardList = res.data.data;
  135. })
  136. },
  137. // 生命周期 - 挂载完成(可以访问DOM元素)
  138. mounted() {},
  139. beforeRouteEnter(to, from, next) {
  140. next((vm) => {
  141. vm.init(vm.proxyObj);
  142. });
  143. },
  144. methods: {
  145. init(row) {
  146. this.proxyObj = row;
  147. this.axios
  148. .get("/api/custom_product_list", {
  149. params: {
  150. page_index: this.page_index,
  151. page_size: this.page_size,
  152. ...row,
  153. },
  154. })
  155. .then((res) => {
  156. console.log(res);
  157. if (res.code == 200) {
  158. this.total = res.data.total;
  159. this.tableData = res.data.data;
  160. }
  161. })
  162. .catch((err) => {
  163. console.error(err);
  164. });
  165. },
  166. searchData(row) {
  167. this.page_index = 1;
  168. this.init(row);
  169. },
  170. handleSet(row, index, type) {
  171. this.type = type;
  172. // 1新增 2编辑 3查看 4删除 5审核 6变更 7变更记录
  173. switch (type) {
  174. case 1:
  175. case 2:
  176. case 3:
  177. this.$router.push({
  178. path: "/cms/BasicSettings/CustomerProductPrice/detail",
  179. query: {
  180. type,
  181. custom_id: row.custom_id,
  182. },
  183. });
  184. break;
  185. case 4:
  186. this.$Modal.confirm({
  187. title: "确认删除?",
  188. content: "此操作无法恢复,请确认!",
  189. onOk: () => {
  190. this.axios({
  191. method: "post",
  192. url: "/api/custom_product_del",
  193. data: {
  194. custom_id: row.custom_id,
  195. },
  196. })
  197. .then((res) => {
  198. this.$Message.success(res.msg);
  199. this.init(this.proxyObj);
  200. })
  201. .catch((err) => {});
  202. },
  203. onCancel: () => {},
  204. });
  205. break;
  206. default:
  207. break;
  208. }
  209. },
  210. changePage(e) {
  211. this.page_index = e;
  212. this.init(this.proxyObj);
  213. },
  214. changeSize(e) {
  215. this.page_size = e;
  216. this.init(this.proxyObj);
  217. },
  218. uploadSuccess(res) {
  219. if (res.code == 200) {
  220. this.$Message.success(res.msg || "上传成功");
  221. } else {
  222. this.$Message.warning(res.msg || "上传失败");
  223. }
  224. this.getData(this.proxyObj);
  225. },
  226. uploadError(err) {
  227. this.$Message.error(err.msg || "上传失败");
  228. },
  229. async exportData() {
  230. const res = await this.axios("/api/parts_classify_export", {
  231. params: { ...this.proxyObj },
  232. });
  233. if (res.code == 200) {
  234. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`;
  235. location.href = url;
  236. }
  237. },
  238. },
  239. // 监听属性 类似于data概念
  240. computed: {
  241. set_list() {
  242. return [
  243. {
  244. title: "客户分类编码",
  245. name: "Input",
  246. value: "",
  247. serverName: "type_code",
  248. placeholder: "请输入客户分类编码",
  249. },
  250. {
  251. title: "客户分类名称",
  252. name: "Input",
  253. value: "",
  254. serverName: "type_title",
  255. placeholder: "请输入客户分类名称",
  256. },
  257. {
  258. title: "客户编码",
  259. name: "Input",
  260. value: "",
  261. serverName: "code",
  262. placeholder: "请输入客户编码",
  263. },
  264. {
  265. title: "客户名称",
  266. name: "Input",
  267. value: "",
  268. serverName: "title",
  269. placeholder: "请输入客户名称",
  270. },
  271. {
  272. title: "审核状态",
  273. name: "Select",
  274. value: "",
  275. placeholder: "请选择审核状态",
  276. serverName: "state",
  277. option: [
  278. { label: "未审核", value: 0 },
  279. { label: "已审核", value: 1 },
  280. ],
  281. },
  282. ];
  283. },
  284. },
  285. beforeRouteLeave(to, from, next) {
  286. if (to.path == "/cms/BasicSettings/CustomerProductPrice/detail") {
  287. this.$route.meta.keepAlive = true;
  288. } else {
  289. this.$route.meta.keepAlive = false;
  290. }
  291. next();
  292. },
  293. // 监控data中的数据变化
  294. watch: {},
  295. beforeCreate() {}, // 生命周期 - 创建之前
  296. beforeMount() {}, // 生命周期 - 挂载之前
  297. beforeUpdate() {}, // 生命周期 - 更新之前
  298. updated() {}, // 生命周期 - 更新之后
  299. beforeDestroy() {}, // 生命周期 - 销毁之前
  300. destroyed() {}, // 生命周期 - 销毁完成
  301. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  302. };
  303. </script>
  304. <style lang="scss" scoped></style>