index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <seek-page :seekList="seekList" @search="search"></seek-page>
  5. <el-tabs
  6. v-model="activeName"
  7. @tab-click="handleClick"
  8. type="card"
  9. style="margin-top: 5px"
  10. >
  11. <el-tab-pane label="全部样品" name="1"></el-tab-pane>
  12. <el-tab-pane label="整样样品" name="2"></el-tab-pane>
  13. <el-tab-pane label="小样样品" name="3"></el-tab-pane>
  14. </el-tabs>
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. :datasource="datasource"
  19. :pageSize="20"
  20. >
  21. <!-- 表头工具栏 -->
  22. <template v-slot:toolbar>
  23. <el-button
  24. size="small"
  25. type="primary"
  26. icon="el-icon-plus"
  27. class="ele-btn-icon"
  28. @click="openEdit('add')"
  29. >
  30. 新增
  31. </el-button>
  32. </template>
  33. <template v-slot:sampleCode="{ row }">
  34. <el-link
  35. type="primary"
  36. :underline="false"
  37. @click="goDetail(row.id, 'detail')"
  38. >{{ row.sampleCode }}</el-link
  39. >
  40. </template>
  41. <!-- 操作列 -->
  42. <template v-slot:action="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. icon="el-icon-edit"
  47. @click="openEdit('edit', row)"
  48. >
  49. 修改
  50. </el-link>
  51. <el-link
  52. type="primary"
  53. :underline="false"
  54. @click="goDetail(row.id)"
  55. v-if="row.status !== 2"
  56. >
  57. 处置
  58. </el-link>
  59. <el-popconfirm
  60. class="ele-action"
  61. title="确定要删除吗?"
  62. @confirm="remove(row)"
  63. >
  64. <template v-slot:reference>
  65. <el-link type="danger" :underline="false" icon="el-icon-delete">
  66. 删除
  67. </el-link>
  68. </template>
  69. </el-popconfirm>
  70. </template>
  71. </ele-pro-table>
  72. </el-card>
  73. <!-- 新增的dialog -->
  74. <sample ref="sampleRef" @done="reload"></sample>
  75. </div>
  76. </template>
  77. <script>
  78. import sample from './components/addOrEditSample.vue';
  79. import { getList, removeItem } from '@/api/samplemanagement';
  80. import dictMixins from '@/mixins/dictMixins';
  81. export default {
  82. mixins: [dictMixins],
  83. components: {
  84. sample
  85. },
  86. data() {
  87. return {
  88. columns: [
  89. {
  90. type: 'index',
  91. columnKey: 'index',
  92. align: 'center',
  93. label: '序号',
  94. width: 55,
  95. showOverflowTooltip: true
  96. },
  97. {
  98. prop: 'sampleCode',
  99. label: '编码',
  100. slot: 'sampleCode',
  101. align: 'center',
  102. width: 160,
  103. showOverflowTooltip: true
  104. },
  105. {
  106. prop: 'sourceCode',
  107. label: '来源编码',
  108. align: 'center',
  109. width: 160,
  110. showOverflowTooltip: true
  111. },
  112. {
  113. prop: 'categoryCode',
  114. label: '物品编码',
  115. align: 'center',
  116. width: 160,
  117. showOverflowTooltip: true
  118. },
  119. {
  120. prop: 'categoryName',
  121. label: '物品名称',
  122. align: 'center',
  123. width: 160,
  124. showOverflowTooltip: true
  125. },
  126. {
  127. prop: 'specification',
  128. label: '规格',
  129. align: 'center',
  130. width: 100,
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'brandNum',
  135. label: '牌号',
  136. align: 'center',
  137. width: 100,
  138. showOverflowTooltip: true
  139. },
  140. {
  141. prop: 'modelType',
  142. label: '型号',
  143. align: 'center',
  144. width: 160,
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'unit',
  149. label: '计量单位',
  150. align: 'center',
  151. width: 100,
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'batchNo',
  156. label: '批次号',
  157. align: 'center',
  158. width: 100,
  159. showOverflowTooltip: true
  160. },
  161. {
  162. prop: 'quantity',
  163. label: '样品数量',
  164. align: 'center',
  165. width: 100,
  166. showOverflowTooltip: true
  167. },
  168. {
  169. prop: 'weight',
  170. label: '重量',
  171. align: 'center',
  172. width: 100,
  173. showOverflowTooltip: true
  174. },
  175. {
  176. prop: 'weightUnit',
  177. label: '重量单位',
  178. align: 'center',
  179. width: 100,
  180. showOverflowTooltip: true
  181. },
  182. {
  183. prop: 'disposeTime',
  184. label: '处置时间',
  185. align: 'center',
  186. width: 180,
  187. showOverflowTooltip: true
  188. },
  189. {
  190. prop: 'status',
  191. label: '状态',
  192. align: 'center',
  193. width: 80,
  194. formatter: (row, column, cellValue) => {
  195. return this.getDictName('处置状态', cellValue);
  196. }
  197. },
  198. {
  199. columnKey: 'action',
  200. label: '操作',
  201. align: 'center',
  202. width: 180,
  203. resizable: false,
  204. slot: 'action',
  205. fixed: 'right'
  206. }
  207. ],
  208. activeName: '1'
  209. };
  210. },
  211. created() {
  212. this.requestDict('处置状态');
  213. },
  214. computed: {
  215. seekList() {
  216. return [
  217. {
  218. label: '编码:',
  219. value: 'sampleCode',
  220. type: 'input',
  221. placeholder: ''
  222. },
  223. {
  224. label: '来源编码:',
  225. value: 'sourceCode',
  226. type: 'input',
  227. placeholder: ''
  228. },
  229. {
  230. label: '物品编码:',
  231. value: 'categoryCode',
  232. type: 'input',
  233. placeholder: ''
  234. },
  235. {
  236. label: '物品名称:',
  237. value: 'categoryName',
  238. type: 'input',
  239. placeholder: ''
  240. },
  241. {
  242. label: '状态:',
  243. value: 'status',
  244. type: 'select',
  245. placeholder: '',
  246. planList: [
  247. { value: 0, label: '待处置' },
  248. { value: 1, label: '部分处置' },
  249. { value: 2, label: '处置完成' }
  250. ]
  251. }
  252. ];
  253. }
  254. },
  255. methods: {
  256. datasource({ page, where, limit }) {
  257. return getList({
  258. ...where,
  259. pageNum: page,
  260. size: limit
  261. });
  262. },
  263. search(where) {
  264. this.reload(where);
  265. },
  266. reload(where = {}) {
  267. this.$nextTick(() => {
  268. where.conditionType =
  269. this.activeName == '1' ? '' : this.activeName == '2' ? '1' : '2';
  270. this.$refs.table.reload({ page: 1, where });
  271. // where.statusList = (
  272. // where.status || this.statusOpt[this.activeName][0].value
  273. // ).split(',');
  274. // this.$refs.table.reload({ page: 1, where });
  275. });
  276. // this.$refs.table.reload({ page: 1, where });
  277. },
  278. goDetail(id, type) {
  279. this.$router.push({
  280. path: '/sample/samplemanagement/detailList',
  281. query: {
  282. id,
  283. type
  284. }
  285. });
  286. },
  287. handleClick(tab) {
  288. this.activeName = tab.name;
  289. this.reload();
  290. },
  291. openEdit(type, row) {
  292. this.$refs.sampleRef.open(type, row);
  293. },
  294. remove(item) {
  295. removeItem([item.id])
  296. .then((message) => {
  297. this.$message.success(message);
  298. this.reload();
  299. })
  300. .catch((e) => {});
  301. }
  302. }
  303. };
  304. </script>
  305. <style scoped></style>