DialogGoods.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="dialogBox">
  3. <el-dialog
  4. :close-on-click-modal="false"
  5. :append-to-body="appendToBody"
  6. :title="title"
  7. :visible.sync="visibleSync"
  8. :before-close="close"
  9. :width="width"
  10. :custom-class="customClass"
  11. >
  12. <ele-split-layout
  13. width="256px"
  14. allow-collapse
  15. :right-style="{ overflow: 'hidden' }"
  16. >
  17. <div>
  18. <div class="select">
  19. <el-select
  20. size="small"
  21. @change="productChange"
  22. v-model="productId"
  23. placeholder="请选择"
  24. >
  25. <el-option
  26. v-for="item in productList"
  27. :label="item.name"
  28. :value="item.id"
  29. :key="item.id"
  30. >
  31. </el-option>
  32. </el-select>
  33. </div>
  34. <div class="tree">
  35. <asset-tree
  36. @handleNodeClick="handleNodeClick"
  37. ref="AssetTree"
  38. :paramsType="'type'"
  39. :init="false"
  40. id="4"
  41. />
  42. </div>
  43. </div>
  44. <!-- <div class="minHeight ele-border-lighter split-layout-right-content">
  45. <template> </template>
  46. </div> -->
  47. <template v-slot:content>
  48. <!-- 数据表格 -->
  49. <ele-pro-table
  50. ref="table"
  51. :initLoad="false"
  52. :columns="columns"
  53. height="60vh"
  54. :current.sync="current"
  55. highlight-current-row
  56. :datasource="datasource"
  57. tool-class="ele-toolbar-form"
  58. cache-key="systemOrgUserTable"
  59. @row-click="chooseRow"
  60. >
  61. <!-- 表头工具栏 -->
  62. <template v-slot:toolbar>
  63. <el-row :gutter="22">
  64. <el-col :span="8">
  65. <el-input
  66. type="text"
  67. v-model="searchForm.searchKey"
  68. size="small"
  69. placeholder="搜索物品编码/名称"
  70. ></el-input>
  71. </el-col>
  72. <el-col :span="8">
  73. <el-button
  74. icon="el-icon-refresh-left"
  75. size="small"
  76. @click="rest"
  77. >重置</el-button
  78. >
  79. <el-button
  80. type="primary"
  81. icon="el-icon-search"
  82. size="small"
  83. @click="reload"
  84. >搜索</el-button
  85. >
  86. </el-col>
  87. </el-row>
  88. </template>
  89. <template v-slot:action="{ row }">
  90. <el-radio class="radio" v-model="radio" :label="row.id"
  91. ><i></i
  92. ></el-radio>
  93. </template>
  94. </ele-pro-table>
  95. </template>
  96. </ele-split-layout>
  97. <footer slot="footer">
  98. <el-button @click="close">取消</el-button>
  99. <el-button @click="submit" type="primary">确认</el-button>
  100. </footer>
  101. </el-dialog>
  102. </div>
  103. </template>
  104. <script>
  105. import AssetTree from '@/components/AssetTree';
  106. // import { getList } from "@/api/stockManagement/itemInformation";
  107. import { getList } from '@/api/classifyManage/itemInformation';
  108. import dictMixins from '@/mixins/dictMixins';
  109. import { getTreeByPid } from '@/api/classifyManage';
  110. export default {
  111. mixins: [dictMixins],
  112. props: {
  113. // 宽度
  114. width: {
  115. type: String,
  116. default: () => null
  117. },
  118. // 类名
  119. customClass: {
  120. type: String,
  121. default: () => null
  122. },
  123. appendToBody: {
  124. type: Boolean,
  125. default: () => false
  126. }
  127. },
  128. components: {
  129. AssetTree
  130. },
  131. data() {
  132. return {
  133. productId: '',
  134. visibleSync: false,
  135. title: '选择物品',
  136. searchForm: {
  137. searchKey: '',
  138. categoryLevelId: '1'
  139. },
  140. current: {},
  141. radio: null,
  142. productList: []
  143. };
  144. },
  145. computed: {
  146. // 表格列配置
  147. columns() {
  148. return [
  149. {
  150. columnKey: 'index',
  151. type: 'index',
  152. width: 80,
  153. label: '序号',
  154. align: 'center',
  155. showOverflowTooltip: true,
  156. fixed: 'left'
  157. },
  158. {
  159. prop: 'code',
  160. label: '物品编码',
  161. showOverflowTooltip: true
  162. },
  163. {
  164. prop: 'name',
  165. label: '物品名称',
  166. showOverflowTooltip: true
  167. },
  168. {
  169. prop: 'specification',
  170. label: '规格',
  171. showOverflowTooltip: true
  172. },
  173. {
  174. prop: 'modelType',
  175. label: '型号',
  176. showOverflowTooltip: true
  177. },
  178. // {
  179. // prop: 'type',
  180. // label: '物品类型',
  181. // showOverflowTooltip: true,
  182. // formatter: (_row) => this.getDictValue('类型用途', _row.type)
  183. // },
  184. {
  185. prop: 'categoryLevelPath',
  186. label: '分类',
  187. showOverflowTooltip: true
  188. },
  189. {
  190. columnKey: 'action',
  191. slot: 'action',
  192. align: 'center',
  193. fixed: 'right',
  194. width: 50
  195. }
  196. ];
  197. }
  198. },
  199. created() {
  200. this.requestDict('类型用途');
  201. },
  202. methods: {
  203. productChange(e) {
  204. this.$refs.AssetTree.getTreeData(e);
  205. },
  206. /* 表格数据源 */
  207. datasource({ page, limit, where }) {
  208. return getList({
  209. ...where,
  210. pageNum: page,
  211. size: limit
  212. });
  213. },
  214. reload() {
  215. this.radio = null;
  216. this.$nextTick(() => {
  217. this.$refs.table.reload({
  218. pageNum: 1,
  219. where: {
  220. ...this.searchForm
  221. }
  222. });
  223. });
  224. },
  225. async open(id, boolen) {
  226. this.visibleSync = true;
  227. const { data } = await getTreeByPid(id);
  228. this.productList = data;
  229. this.$refs.AssetTree.getTreeData(id, boolen);
  230. this.productId = '';
  231. },
  232. close() {
  233. this.visibleSync = false;
  234. },
  235. rest() {
  236. this.searchForm.searchKey = '';
  237. this.reload();
  238. },
  239. handleNodeClick(info) {
  240. this.searchForm.categoryLevelId = info.id;
  241. this.reload();
  242. },
  243. chooseRow(row) {
  244. this.current = row;
  245. this.radio = row.id;
  246. },
  247. submit() {
  248. if (!this.current) {
  249. return this.$message.error('请选择物品编码');
  250. }
  251. this.$emit('succeed', this.current);
  252. this.close();
  253. }
  254. }
  255. };
  256. </script>
  257. <style lang="scss" scoped>
  258. .select {
  259. background: #fafafa;
  260. border: 1px solid #ededed;
  261. border-bottom: none;
  262. padding: 9px 15px;
  263. .el-select {
  264. width: 100%;
  265. }
  266. }
  267. .tree {
  268. height: calc(100vh - 280px);
  269. border: 1px solid #ededed;
  270. }
  271. .from-search-bar {
  272. display: flex;
  273. .btn-wrap {
  274. margin-left: 20px;
  275. }
  276. }
  277. .main {
  278. display: flex;
  279. .tree-col {
  280. margin-right: 10px;
  281. width: 350px;
  282. height: 500px;
  283. overflow-y: auto;
  284. padding: 0 !important;
  285. background-color: #fff;
  286. margin-top: 10px;
  287. border: 1px solid #e6ebf5;
  288. border-radius: 4px;
  289. overflow-x: auto;
  290. box-sizing: border-box;
  291. }
  292. .right-wrap {
  293. width: 100%;
  294. margin-top: 10px;
  295. .tableRef {
  296. height: 450px;
  297. }
  298. .btn-wrap {
  299. display: flex;
  300. justify-content: flex-end;
  301. margin-top: 20px;
  302. }
  303. }
  304. }
  305. </style>