product-management.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!-- 产品管理 -->
  2. <template>
  3. <div class="product-management">
  4. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  5. <el-form-item label="名称">
  6. <el-input v-model="dataForm.productName" placeholder="产品名称" clearable/>
  7. </el-form-item>
  8. <el-form-item label="产品类别">
  9. <el-select
  10. v-model="dataForm.productType"
  11. remote
  12. placeholder="请选择">
  13. <el-option
  14. v-for="item in optionsType"
  15. :key="item.code"
  16. :label="item.value"
  17. :value="item.code">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button @click="search()">查询</el-button>
  23. <el-button v-if="isAuth('pro:product:save')" type="primary" @click="addOrUpdateHandle(0, false)">创建新产品</el-button>
  24. </el-form-item>
  25. </el-form>
  26. <el-table
  27. :data="dataList"
  28. border
  29. v-loading="dataListLoading"
  30. style="width: 100%;">
  31. <el-table-column
  32. label="序号"
  33. type="index"
  34. width="50"
  35. align="center">
  36. </el-table-column>
  37. <el-table-column
  38. prop="productCode"
  39. header-align="center"
  40. align="center"
  41. min-width="100"
  42. label="产品编码">
  43. </el-table-column>
  44. <el-table-column
  45. prop="productName"
  46. header-align="center"
  47. align="center"
  48. min-width="120"
  49. label="产品名称">
  50. </el-table-column>
  51. <el-table-column
  52. prop="productType"
  53. header-align="center"
  54. align="center"
  55. :formatter="typeFormat"
  56. label="产品类别">
  57. </el-table-column>
  58. <el-table-column
  59. prop="isCompose"
  60. header-align="center"
  61. align="center"
  62. :formatter="composeFormat"
  63. label="是否组合产品">
  64. </el-table-column>
  65. <el-table-column
  66. prop="sourceName"
  67. header-align="center"
  68. align="center"
  69. min-width="200"
  70. :show-overflow-tooltip="true"
  71. label="来源">
  72. </el-table-column>
  73. <el-table-column
  74. prop="createTime"
  75. header-align="center"
  76. align="center"
  77. min-width="160"
  78. label="创建时间">
  79. </el-table-column>
  80. <el-table-column
  81. prop="creatorName"
  82. header-align="center"
  83. align="center"
  84. min-width="100"
  85. label="创建人">
  86. </el-table-column>
  87. <el-table-column
  88. prop="notes"
  89. header-align="center"
  90. align="center"
  91. min-width="180"
  92. :show-overflow-tooltip="true"
  93. label="备注">
  94. </el-table-column>
  95. <el-table-column
  96. header-align="center"
  97. align="center"
  98. label="配料清单">
  99. <template slot-scope="scope">
  100. <el-button type="text" size="small" @click="materialDetails(scope.row.coId, true)">查看</el-button>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. header-align="center"
  105. align="center"
  106. label="对应图纸">
  107. <template slot-scope="scope">
  108. <el-button type="text" size="small" @click="drawDetails(scope.row.coId, true)">查看</el-button>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. header-align="center"
  113. align="center"
  114. label="对应工艺">
  115. <template slot-scope="scope">
  116. <el-button type="text" size="small" @click="techDetails(scope.row.coId, true)">查看</el-button>
  117. </template>
  118. </el-table-column>
  119. <el-table-column
  120. fixed="right"
  121. header-align="center"
  122. align="center"
  123. width="150"
  124. label="操作">
  125. <template slot-scope="scope">
  126. <el-button v-if="isAuth('pro:product:info')" type="text" size="small" @click="detailHandle(scope.row.productId)">查看</el-button>
  127. <el-button v-if="isAuth('pro:product:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.productId, false)">编辑</el-button>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <el-pagination
  132. @size-change="sizeChangeHandle"
  133. @current-change="currentChangeHandle"
  134. :current-page="pageIndex"
  135. :page-sizes="[10, 20, 50, 100]"
  136. :page-size="pageSize"
  137. :total="totalPage"
  138. layout="total, sizes, prev, pager, next, jumper">
  139. </el-pagination>
  140. <!-- 弹窗, 新增 / 修改 -->
  141. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  142. <detail v-if="detailVisible" ref="detail"/>
  143. </div>
  144. </template>
  145. <script>
  146. import AddOrUpdate from './product-add-or-update'
  147. import Detail from './product-detail'
  148. import { getDictList } from '@/api/dict'
  149. import { getProductList } from '@/api/product'
  150. export default {
  151. name: 'product-management',
  152. components: {
  153. AddOrUpdate, Detail
  154. },
  155. data () {
  156. return {
  157. addOrUpdateVisible: false,
  158. detailVisible: false,
  159. dataForm: {},
  160. dataList: [],
  161. pageIndex: 1,
  162. pageSize: 10,
  163. totalPage: 0,
  164. dataListLoading: false,
  165. dataListSelections: [],
  166. optionsType: []
  167. }
  168. },
  169. created () {
  170. this.getTypeList()
  171. // this.getStateList()
  172. this.getDataList()
  173. },
  174. methods: {
  175. // 获取产品类别字典
  176. getTypeList () {
  177. getDictList({type: 'product_type'}).then(({data}) => {
  178. if (data) {
  179. this.optionsType = data
  180. }
  181. })
  182. },
  183. // 查询
  184. search () {
  185. this.pageIndex = 1
  186. this.getDataList()
  187. },
  188. // 获取数据列表
  189. getDataList () {
  190. this.dataListLoading = true
  191. this.addOrUpdateVisible = false
  192. let params = {
  193. 'current': this.pageIndex,
  194. 'size': this.pageSize,
  195. 'productName': this.dataForm.productName ? this.dataForm.productName : null,
  196. 'productType': this.dataForm.productType ? this.dataForm.productType : null
  197. }
  198. getProductList(params).then(({data}) => {
  199. if (data && data.code === '200') {
  200. this.dataList = data.data.records
  201. this.totalPage = Number(data.data.total)
  202. } else {
  203. this.dataList = []
  204. this.totalPage = 0
  205. }
  206. this.dataListLoading = false
  207. })
  208. },
  209. deleteHandle (id) {
  210. if (!id) return
  211. let ids = []
  212. ids.push(id)
  213. this.$confirm(`确定删除?`, '提示', {
  214. confirmButtonText: '确定',
  215. cancelButtonText: '取消',
  216. type: 'warning'
  217. }).then(() => {
  218. this.$http({
  219. url: this.$http.adornUrl(`/biz-service/product/delete`),
  220. method: 'DELETE',
  221. data: ids
  222. }).then(({data}) => {
  223. if (data && data.code === '200') {
  224. this.$message({
  225. message: '操作成功',
  226. type: 'success',
  227. duration: 1500,
  228. onClose: () => {
  229. this.getDataList()
  230. }
  231. })
  232. } else {
  233. this.$message.error(data.msg)
  234. }
  235. })
  236. }).catch(() => {})
  237. },
  238. // 每页数
  239. sizeChangeHandle (val) {
  240. this.pageSize = val
  241. this.pageIndex = 1
  242. this.getDataList()
  243. },
  244. // 当前页
  245. currentChangeHandle (val) {
  246. this.pageIndex = val
  247. this.getDataList()
  248. },
  249. // 多选
  250. selectionChangeHandle (val) {
  251. this.dataListSelections = val
  252. },
  253. // 新增 / 修改
  254. addOrUpdateHandle (id, disable) {
  255. this.addOrUpdateVisible = true
  256. this.$nextTick(() => {
  257. this.$refs.addOrUpdate.init(id, disable)
  258. })
  259. },
  260. // 转换属性“产品类别”
  261. typeFormat (row) {
  262. if (this.optionsType) {
  263. for (let i = 0; i < this.optionsType.length; i++) {
  264. if (this.optionsType[i].code === row.productType) {
  265. return this.optionsType[i].value
  266. }
  267. }
  268. }
  269. },
  270. // 转换属性“是否组合产品”
  271. composeFormat (row) {
  272. if (row.isCompose === 1) {
  273. return '是'
  274. } else return '否'
  275. },
  276. // 详情
  277. detailHandle (id) {
  278. this.detailVisible = true
  279. this.$nextTick(() => {
  280. this.$refs.detail.init(id)
  281. })
  282. }
  283. }
  284. }
  285. </script>
  286. <style scoped>
  287. </style>