index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. :table-loading="loading"
  12. :cell-style="cellStyle"
  13. @selection-change="selectionChange"
  14. @search-change="searchChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad"
  19. @search-criteria-switch="searchCriteriaSwitch"
  20. @saveColumn="saveColumn"
  21. @resetColumn="resetColumn"
  22. >
  23. <template slot="menuLeft">
  24. <el-button
  25. type="primary"
  26. icon="el-icon-plus"
  27. size="small"
  28. @click.stop="newAdd()"
  29. >创建单据</el-button>
  30. <el-button
  31. type="success"
  32. size="small"
  33. icon="el-icon-plus"
  34. @click.stop="copyDoc()"
  35. :disabled="selection.length != 1"
  36. >复制单据</el-button>
  37. </template>
  38. <template slot-scope="scope" slot="menu">
  39. <el-button
  40. type="text"
  41. icon="el-icon-delete"
  42. size="small"
  43. @click.stop="rowDel(scope.row, scope.index)"
  44. :disabled="scope.row.status == 3"
  45. >删除
  46. </el-button>
  47. </template>
  48. <template slot="corpNameSearch">
  49. <crop-select
  50. v-model="search.corpId"
  51. corpType="KH"
  52. ></crop-select>
  53. </template>
  54. <template slot="createUserSearch">
  55. <el-select
  56. v-model="search.createUser"
  57. filterable
  58. clearable
  59. placeholder="请选择 承揽人"
  60. >
  61. <el-option
  62. v-for="(item, index) in contractorOption"
  63. :key="index"
  64. :value="item.realName"
  65. :label="item.realName"
  66. ></el-option>
  67. </el-select>
  68. </template>
  69. <template slot="oppositePersonSearch">
  70. <el-select
  71. v-model="search.oppositePerson"
  72. filterable
  73. clearable
  74. placeholder="请选择 承揽人"
  75. >
  76. <el-option
  77. v-for="(item, index) in oppositePersonOption"
  78. :key="index"
  79. :value="item.realName"
  80. :label="item.realName"
  81. ></el-option>
  82. </el-select>
  83. </template>
  84. </avue-crud>
  85. </basic-container>
  86. <detail-page
  87. @goBack="goBack"
  88. @copyOrder="copyOrder"
  89. :detailData="detailData"
  90. v-if="!show"
  91. />
  92. </div>
  93. </template>
  94. <script>
  95. import option from "./config/mainList.json";
  96. import detailPage from "./detail";
  97. import { gainUser } from "@/api/basicData/customerInquiry";
  98. export default {
  99. name: "index",
  100. components: {
  101. detailPage,
  102. },
  103. data() {
  104. return {
  105. option: {},
  106. dataList: [],
  107. form: {},
  108. page: {
  109. pageSize: 10,
  110. currentPage: 1,
  111. total: 0,
  112. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  113. },
  114. search: {},
  115. show: true,
  116. loading: false,
  117. selection: [],
  118. detailData: {},
  119. contractorOption: [],
  120. oppositePersonOption: [],
  121. }
  122. },
  123. async created() {
  124. this.option = await this.getColumnData(this.getColumnName(101), option);
  125. gainUser().then(res => {
  126. this.contractorOption = res.data.data;
  127. this.oppositePersonOption = res.data.data;
  128. })
  129. },
  130. methods: {
  131. searchCriteriaSwitch(type) {
  132. // if (type){
  133. // this.option.height = this.option.height - 90
  134. // }else {
  135. // this.option.height = this.option.height + 90
  136. // }
  137. // this.$refs.crud.getTableHeight()
  138. },
  139. newAdd() {
  140. this.show = false;
  141. },
  142. onLoad(page, params) {
  143. // 重置掉展开
  144. this.dataList.forEach(item => {
  145. this.$refs.crud.toggleRowExpansion(item, false)
  146. })
  147. let queryParams = Object.assign({}, params, {
  148. size: page.pageSize,
  149. current: page.currentPage,
  150. })
  151. // this.loading = true;
  152. // getSalesList(queryParams).then(res => {
  153. // this.dataList = res.data.data.records;
  154. // this.page.total = res.data.data.total;
  155. // this.option.height = window.innerHeight - 240;
  156. // this.$nextTick(() => {
  157. // this.$refs.crud.doLayout()
  158. // })
  159. // }).finally(() => {
  160. // this.loading = false;
  161. // })
  162. },
  163. async saveColumn() {
  164. const inSave = await this.saveColumnData(
  165. this.getColumnName(101),
  166. this.option
  167. );
  168. if (inSave) {
  169. this.$message.success("保存成功");
  170. //关闭窗口
  171. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  172. this.$nextTick(() => {
  173. this.$refs.crud.doLayout()
  174. })
  175. }
  176. },
  177. async resetColumn() {
  178. this.option = option;
  179. const inSave = await this.delColumnData(this.getColumnName(101), option);
  180. if (inSave) {
  181. this.$nextTick(() => {
  182. this.$refs.crud.doLayout()
  183. })
  184. this.$message.success("重置成功");
  185. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  186. }
  187. },
  188. //点击搜索按钮触发
  189. searchChange(params, done) {
  190. this.onLoad(this.page, params);
  191. done();
  192. },
  193. currentChange(val) {
  194. this.page.currentPage = val;
  195. },
  196. sizeChange(val) {
  197. this.page.currentPage = 1;
  198. this.page.pageSize = val;
  199. },
  200. refreshChange() {
  201. this.onLoad(this.page, this.search);
  202. },
  203. cellStyle() {
  204. return "padding:0;height:40px;";
  205. },
  206. copyDoc() {},
  207. selectionChange(list) {
  208. this.selection = list;
  209. },
  210. goBack() {
  211. if (this.$route.query) {
  212. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  213. this.$router.push({
  214. path: "/saleLeads/index"
  215. });
  216. }
  217. this.detailData = this.$options.data().detailData;
  218. this.show = true;
  219. this.onLoad(this.page, this.search);
  220. },
  221. copyOrder(id) {
  222. this.show = true;
  223. this.detailData = {
  224. id: id,
  225. status: "copy"
  226. };
  227. this.$nextTick(() => {
  228. this.show = false;
  229. });
  230. },
  231. contractorRemoteMethod(name) {
  232. gainUser({realName: name}).then(res => {
  233. this.contractorOption = res.data.data;
  234. })
  235. },
  236. oppositePersonRemoteMethod(name) {
  237. gainUser({realName: name}).then(res => {
  238. this.oppositePerson = res.data.data;
  239. })
  240. },
  241. },
  242. }
  243. </script>
  244. <style scoped>
  245. </style>