index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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: 'batchNo',
  128. label: '批次号',
  129. align: 'center',
  130. width: 100,
  131. showOverflowTooltip: true
  132. },
  133. {
  134. prop: 'specification',
  135. label: '规格',
  136. align: 'center',
  137. width: 100,
  138. showOverflowTooltip: true
  139. },
  140. {
  141. prop: 'brandNum',
  142. label: '牌号',
  143. align: 'center',
  144. width: 100,
  145. showOverflowTooltip: true
  146. },
  147. {
  148. prop: 'modelType',
  149. label: '型号',
  150. align: 'center',
  151. width: 160,
  152. showOverflowTooltip: true
  153. },
  154. {
  155. prop: 'quantity',
  156. label: '样品数量',
  157. align: 'center',
  158. width: 100,
  159. showOverflowTooltip: true
  160. },
  161. // {
  162. // prop: 'unit',
  163. // label: '计量单位',
  164. // align: 'center',
  165. // width: 100,
  166. // showOverflowTooltip: true
  167. // },
  168. {
  169. prop: 'disposeTime',
  170. label: '处置时间',
  171. align: 'center',
  172. width: 180,
  173. showOverflowTooltip: true
  174. },
  175. {
  176. prop: 'status',
  177. label: '状态',
  178. align: 'center',
  179. width: 80,
  180. formatter: (row, column, cellValue) => {
  181. console.log(this.getDictName('处置状态', cellValue));
  182. return this.getDictName('处置状态', cellValue);
  183. }
  184. },
  185. {
  186. columnKey: 'action',
  187. label: '操作',
  188. align: 'center',
  189. width: 180,
  190. resizable: false,
  191. slot: 'action',
  192. fixed: 'right'
  193. }
  194. ],
  195. activeName: '1'
  196. };
  197. },
  198. created() {
  199. this.requestDict('处置状态');
  200. },
  201. computed: {
  202. seekList() {
  203. return [
  204. {
  205. label: '编码:',
  206. value: 'sampleCode',
  207. type: 'input',
  208. placeholder: ''
  209. },
  210. {
  211. label: '来源编码:',
  212. value: 'sourceCode',
  213. type: 'input',
  214. placeholder: ''
  215. },
  216. {
  217. label: '物品编码:',
  218. value: 'categoryCode',
  219. type: 'input',
  220. placeholder: ''
  221. },
  222. {
  223. label: '物品名称:',
  224. value: 'categoryName',
  225. type: 'input',
  226. placeholder: ''
  227. },
  228. {
  229. label: '状态:',
  230. value: 'status',
  231. type: 'select',
  232. placeholder: '',
  233. planList: [
  234. { value: 0, label: '待处置' },
  235. { value: 1, label: '部分处置' },
  236. { value: 2, label: '处置完成' }
  237. ]
  238. }
  239. ];
  240. }
  241. },
  242. methods: {
  243. datasource({ page, where, limit }) {
  244. return getList({
  245. ...where,
  246. pageNum: page,
  247. size: limit
  248. });
  249. },
  250. search(where) {
  251. this.reload(where);
  252. },
  253. reload(where = {}) {
  254. this.$nextTick(() => {
  255. where.conditionType =
  256. this.activeName == '1' ? '' : this.activeName == '2' ? '1' : '2';
  257. this.$refs.table.reload({ page: 1, where });
  258. });
  259. },
  260. goDetail(id, type) {
  261. this.$router.push({
  262. path: '/sample/samplemanagement/detailList',
  263. query: {
  264. id,
  265. type
  266. }
  267. });
  268. },
  269. handleClick(tab) {
  270. this.activeName = tab.name;
  271. this.reload();
  272. },
  273. openEdit(type, row) {
  274. this.$refs.sampleRef.open(type, row);
  275. },
  276. remove(item) {
  277. removeItem([item.id])
  278. .then((message) => {
  279. this.$message.success(message);
  280. this.reload();
  281. })
  282. .catch((e) => {});
  283. }
  284. }
  285. };
  286. </script>
  287. <style scoped></style>