list.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. .catch((err) => {});
  132. // 获取超标方案
  133. this.axios({ method: "get", url: "/api/overdraft_list" })
  134. .then((res) => {
  135. this.overStandardList = res.data.data;
  136. })
  137. .catch((err) => {});
  138. },
  139. // 生命周期 - 挂载完成(可以访问DOM元素)
  140. mounted() {},
  141. methods: {
  142. init(row) {
  143. this.proxyObj = row;
  144. this.axios
  145. .get("/api/custom_product_list", {
  146. params: {
  147. page_index: this.page_index,
  148. page_size: this.page_size,
  149. ...row,
  150. },
  151. })
  152. .then((res) => {
  153. console.log(res);
  154. if (res.code == 200) {
  155. this.total = res.data.total;
  156. this.tableData = res.data.data;
  157. }
  158. })
  159. .catch((err) => {
  160. console.error(err);
  161. });
  162. },
  163. searchData(row) {
  164. this.page_index = 1;
  165. this.init(row);
  166. },
  167. handleSet(row, index, type) {
  168. this.type = type;
  169. // 1新增 2编辑 3查看 4删除 5审核 6变更 7变更记录
  170. switch (type) {
  171. case 1:
  172. case 2:
  173. case 3:
  174. this.$router.push({
  175. path: "/cms/BasicSettings/CustomerProductPrice/detail",
  176. query: {
  177. type,
  178. custom_id: row.custom_id,
  179. },
  180. });
  181. break;
  182. case 4:
  183. this.$Modal.confirm({
  184. title: "确认删除?",
  185. content: "此操作无法恢复,请确认!",
  186. onOk: () => {
  187. this.axios({
  188. method: "post",
  189. url: "/api/custom_product_del",
  190. data: {
  191. custom_id: row.custom_id,
  192. },
  193. })
  194. .then((res) => {
  195. this.$Message.success(res.msg);
  196. this.init(this.proxyObj);
  197. })
  198. .catch((err) => {});
  199. },
  200. onCancel: () => {},
  201. });
  202. break;
  203. default:
  204. break;
  205. }
  206. },
  207. changePage(e) {
  208. this.page_index = e;
  209. this.init(this.proxyObj);
  210. },
  211. changeSize(e) {
  212. this.page_size = e;
  213. this.init(this.proxyObj);
  214. },
  215. uploadSuccess(res) {
  216. if (res.code == 200) {
  217. this.$Message.success(res.msg || "上传成功");
  218. } else {
  219. this.$Message.warning(res.msg || "上传失败");
  220. }
  221. this.getData(this.proxyObj);
  222. },
  223. uploadError(err) {
  224. this.$Message.error(err.msg || "上传失败");
  225. },
  226. async exportData() {
  227. const res = await this.axios("/api/parts_classify_export", {
  228. params: { ...this.proxyObj },
  229. });
  230. if (res.code == 200) {
  231. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`;
  232. location.href = url;
  233. }
  234. },
  235. },
  236. // 监听属性 类似于data概念
  237. computed: {
  238. set_list() {
  239. return [
  240. {
  241. title: "客户分类编码",
  242. name: "Input",
  243. value: "",
  244. serverName: "type_code",
  245. placeholder: "请输入客户分类编码",
  246. },
  247. {
  248. title: "客户分类名称",
  249. name: "Input",
  250. value: "",
  251. serverName: "type_title",
  252. placeholder: "请输入客户分类名称",
  253. },
  254. {
  255. title: "客户编码",
  256. name: "Input",
  257. value: "",
  258. serverName: "code",
  259. placeholder: "请输入客户编码",
  260. },
  261. {
  262. title: "客户名称",
  263. name: "Input",
  264. value: "",
  265. serverName: "title",
  266. placeholder: "请输入客户名称",
  267. },
  268. {
  269. title: "审核状态",
  270. name: "Select",
  271. value: "",
  272. placeholder: "请选择审核状态",
  273. serverName: "state",
  274. option: [
  275. { label: "未审核", value: 0 },
  276. { label: "已审核", value: 1 },
  277. ],
  278. },
  279. ];
  280. },
  281. },
  282. beforeRouteLeave(to, from, next) {
  283. if (to.path == "/cms/BasicSettings/CustomerProductPrice/detail") {
  284. this.$route.meta.keepAlive = true;
  285. } else {
  286. this.$route.meta.keepAlive = false;
  287. }
  288. next();
  289. },
  290. // 监控data中的数据变化
  291. watch: {},
  292. beforeCreate() {}, // 生命周期 - 创建之前
  293. beforeMount() {}, // 生命周期 - 挂载之前
  294. beforeUpdate() {}, // 生命周期 - 更新之前
  295. updated() {}, // 生命周期 - 更新之后
  296. beforeDestroy() {}, // 生命周期 - 销毁之前
  297. destroyed() {}, // 生命周期 - 销毁完成
  298. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  299. };
  300. </script>
  301. <style lang="scss" scoped></style>