index.vue 7.4 KB

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