product-management.vue 8.9 KB

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