productFactory.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="生产厂家选择"
  5. width="1000px"
  6. :close-on-click-modal="false"
  7. :append-to-body="true"
  8. v-dialogDrag
  9. class="userDialog"
  10. :visible.sync="visible"
  11. >
  12. <el-container style="height: 500px">
  13. <el-container>
  14. <el-header style="text-align: left; font-size: 12px; height: 30px">
  15. <el-form
  16. size="small"
  17. :inline="true"
  18. ref="searchForm"
  19. :model="searchForm"
  20. @keyup.enter.native="refreshList()"
  21. @submit.native.prevent
  22. >
  23. <el-form-item prop="code">
  24. <el-input
  25. size="small"
  26. v-model="searchForm.code"
  27. placeholder="物料编号"
  28. clearable
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item prop="name">
  32. <el-input
  33. size="small"
  34. v-model="searchForm.name"
  35. placeholder="物料名称"
  36. clearable
  37. ></el-input>
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button
  41. type="primary"
  42. @click="refreshList()"
  43. size="small"
  44. icon="el-icon-search"
  45. >查询</el-button
  46. >
  47. <el-button
  48. @click="resetSearch()"
  49. size="small"
  50. icon="el-icon-refresh-right"
  51. >重置</el-button>
  52. </el-form-item>
  53. </el-form>
  54. </el-header>
  55. <el-main>
  56. <el-table
  57. :data="dataList"
  58. v-loading="loading"
  59. size="small"
  60. border
  61. ref="contractTable"
  62. @select="handleSelectionChange"
  63. height="calc(100% - 40px)"
  64. style="width: 100%"
  65. >
  66. <el-table-column
  67. type="selection"
  68. header-align="center"
  69. align="center"
  70. width="50"
  71. >
  72. </el-table-column>
  73. <el-table-column
  74. prop="code"
  75. header-align="center"
  76. align="left"
  77. sortable="custom"
  78. min-width="90"
  79. label="code"
  80. >
  81. </el-table-column>
  82. <el-table-column
  83. prop="manufactureName"
  84. header-align="center"
  85. align="left"
  86. sortable="custom"
  87. min-width="90"
  88. label="名称"
  89. >
  90. </el-table-column>
  91. <!-- <el-table-column
  92. prop="contractAmount"
  93. header-align="center"
  94. align="left"
  95. sortable="custom"
  96. min-width="110"
  97. label="合同金额"
  98. >
  99. </el-table-column>
  100. <el-table-column
  101. prop="oppositeCompany"
  102. header-align="center"
  103. align="center"
  104. sortable="custom"
  105. min-width="110"
  106. label="对方单位"
  107. >
  108. </el-table-column>
  109. <el-table-column
  110. prop="signDate"
  111. header-align="center"
  112. align="left"
  113. sortable="custom"
  114. min-width="110"
  115. label="签订时间"
  116. >
  117. </el-table-column> -->
  118. </el-table>
  119. <el-pagination
  120. @size-change="sizeChangeHandle"
  121. @current-change="currentChangeHandle"
  122. :current-page="pageNo"
  123. :page-sizes="[5, 10, 15, 20]"
  124. :page-size="pageSize"
  125. :total="total"
  126. layout="total, sizes, prev, pager, next, jumper"
  127. >
  128. </el-pagination>
  129. </el-main>
  130. </el-container>
  131. </el-container>
  132. <span slot="footer" class="dialog-footer">
  133. <el-button
  134. size="small"
  135. @click="visible = false"
  136. icon="el-icon-circle-close"
  137. >关闭</el-button
  138. >
  139. <el-button
  140. size="small"
  141. type="primary"
  142. icon="el-icon-circle-check"
  143. @click="doSubmit()"
  144. >确定</el-button
  145. >
  146. </span>
  147. </el-dialog>
  148. </div>
  149. </template>
  150. <script>
  151. import { getProductFactory } from '@/api/changeApply/basic'
  152. export default {
  153. data() {
  154. return {
  155. searchForm: {
  156. code: '',
  157. name: ''
  158. },
  159. dataListAllSelections: [], // 所有选中的数据包含跨页数据
  160. idKey: "id", // 标识列表数据中每一行的唯一键的名称(需要按自己的数据改一下)
  161. dataList: [],
  162. pageNo: 1,
  163. pageSize: 10,
  164. total: 0,
  165. orders: [],
  166. loading: false,
  167. visible: false,
  168. };
  169. },
  170. props: {
  171. selectData: {
  172. type: Array,
  173. default: () => {
  174. return [];
  175. },
  176. },
  177. // 是否启用单选
  178. single: {
  179. type: Boolean,
  180. default: false
  181. }
  182. },
  183. methods: {
  184. init() {
  185. this.visible = true;
  186. this.$nextTick(() => {
  187. this.dataListAllSelections = JSON.parse(JSON.stringify(this.selectData));
  188. this.resetSearch();
  189. });
  190. },
  191. // 获取数据列表
  192. refreshList() {
  193. this.loading = true;
  194. // axios({
  195. // url: "http://172.16.62.241:8000/drp-admin/system/material/list", // 自己的接口路径
  196. // method: "post",
  197. // data: {
  198. // // current: this.pageNo,
  199. // size: this.pageSize,
  200. // // orders: this.orders,
  201. // // ...this.searchForm,
  202. // },
  203. getProductFactory({
  204. pageNo: 1,
  205. size: this.pageSize
  206. }).then(({ data }) => {
  207. console.log('data',data)
  208. this.dataList = data.tableBody;
  209. this.total = data.tableBody.length;
  210. this.pageNo = data.current;
  211. this.loading = false;
  212. this.$nextTick(() => {
  213. this.setSelectRow();
  214. });
  215. });
  216. },
  217. // 每页数
  218. sizeChangeHandle(val) {
  219. this.pageSize = val;
  220. this.pageNo = 1;
  221. this.refreshList();
  222. },
  223. // 当前页
  224. currentChangeHandle(val) {
  225. this.pageNo = val;
  226. this.refreshList();
  227. },
  228. // 排序
  229. resetSearch() {
  230. this.$refs.searchForm.resetFields();
  231. this.refreshList();
  232. },
  233. // 选中数据
  234. handleSelectionChange(selection, row) {
  235. if (this.single && selection.length > 1) {
  236. this.$refs.contractTable.clearSelection();
  237. this.$refs.contractTable.toggleRowSelection(row);
  238. }
  239. this.dataListAllSelections = this.single ? [row] : selection
  240. },
  241. // 设置选中的方法
  242. setSelectRow() {
  243. this.$refs.contractTable.clearSelection();
  244. if (!this.dataListAllSelections || this.dataListAllSelections.length <= 0) {
  245. return;
  246. }
  247. for (let i = 0; i < this.dataList.length; i++) {
  248. if (this.dataListAllSelections.some(item => item[this.idKey] == this.dataList[i][this.idKey])) {
  249. // 设置选中,记住table组件需要使用ref="table"
  250. this.$refs.contractTable.toggleRowSelection(this.dataList[i], true);
  251. }
  252. }
  253. },
  254. doSubmit() {
  255. this.visible = false;
  256. console.log('选择的数据?',this.dataListAllSelections)
  257. this.$emit("doSubmit", this.dataListAllSelections);
  258. },
  259. },
  260. };
  261. </script>
  262. <style lang="scss">
  263. .userDialog {
  264. .el-dialog__body {
  265. padding: 10px 0px 0px 10px;
  266. color: #606266;
  267. font-size: 14px;
  268. word-break: break-all;
  269. }
  270. .el-main {
  271. padding: 20px 20px 5px 20px;
  272. .el-pagination {
  273. margin-top: 5px;
  274. }
  275. }
  276. }
  277. </style>